The simplest thing is to convert the URL Based on the URL rewriting (rewrite) module in various web servers:
In this way, the program implementation will be almost unchanged? The link id = 234 is mapped to news/234.html, and looks like a static link from the outside. On the Resin server, you can use web. xml of webinfo to set: the URL rewrite function is powerful enough to write a book.
When I need? When id = 234 is mapped to news/234.html, you only need to set the Web. XML in the directory where web-INF is located:
Add the following statement
<Filter-name = 'rewrite'
Filter-class = 'com. Caucho. Filters. rewritefilter'>
<Init>
<Rewrite pattern = "/(/d +)/. html" target = "// news. jsp /? Id = $1 "/>
// <Rewrite pattern = "/value _ (. +)/. html" target = "// news. jsp /? T = $1 "/> is set as another parameter.
</Init>
</Filter>
<Filter-mapping URL-pattern = '/*' filter-name = 'rewrite'/>
You can explore other methods by yourself. The rewrite function is very powerful.
After this configuration, you can access the original dynamic page through a link like 1234.htm.
There are also some benefits through URL rewrite:
- Hiding background implementation: This is very useful for background application platform migration: when migrating from JSP to ASP, foreground users cannot feel the changes of background applications;
- Simplified data validation: parameters such as (/d +) can effectively control the number format and even digits;
For example, we need to extract the application from news. jsp? Id = 234 migrate to news. php? When query is set to 234, the foreground performance can always be news/234.html. Separating the application from the foreground: This ensures the stability of the URL, while using mod_rewrite can even forward requests to other backend servers.