After careful consideration, we found that when we entered hi.csdn.net/##in csdn, there was not a jsp PHP page, but it was directed to another place. Here ** the user name can be used to hide the address and pass parameters. Assign a path to each user. However, the error page 301 is not redirected here. For example, www.ttsmm.com. Here we do 301. When the user enters ttsmm.com, the browser will automatically jump to www.ttsmm.com 301.
This method is pseudo-static. Some static rules are required to move to the past.
Implementation Method:
1. Download urlrewrite, official: http://tuckey.org/urlrewrite/dist/urlrewritefilter-2.6.zip
2. decompress the file and copy the file in the package to the project (package location-> Project location ):
Urlrewrite-2.6.0-src/webapp/WEB-INF/lib/urlrewrite-2.6.0.jar-> webroot/WEB-INF/lib/urlrewrite-2.6.0.jar
Urlrewrite-2.6.0-src/webapp/WEB-INF/urlrewrite. XML-> webroot/WEB-INF/urlrewrite. xml
Web. xml configuration:
<Filter> <br/> <filter-Name> urlrewritefilter </filter-Name> <br/> <filter-class> <br/> Org. tuckey. web. filters. urlrewrite. urlrewritefilter <br/> </filter-class> <br/> </filter> <br/> <filter-mapping> <br/> <filter-Name> urlrewritefilter </ filter-Name> <br/> <URL-pattern>/* </url-pattern> <br/> </filter-mapping> <br/>
Modify urlrewrite. xml
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <! Doctype urlrewrite public "-// tuckey.org//dtd urlrewrite 2.6 // en" <br/> "http://tuckey.org/res/dtds/urlrewrite2.6.dtd"> </P> <p> <! -- </P> <p> configuration file for urlrewritefilter </P> <p> http://tuckey.org/urlrewrite/ </P> <p> --> <br/> <urlrewrite> <br/> <rule> <br/> <from> ^/([A-Z] +) $ </from> <br/> <to type = "Forward">/World. JSP? Id = $1 </to> <br/> </Rule> <br/> <rule> <br/> <from> ^/World /(. *) $ </from> <br/> <to>/World. JSP? Tid = $1 </to> <br/> </Rule> <br/> <rule> <br/> <from> ^ /(. * pai.html $ </from> <br/> <to>/test1/$ 1.jsp</to> <br/> </Rule> </P> <p> <outbound- rule> <br/> <Note> <br/> the outbound-rule specifies that when response. encodeurl is called (if you are using jstl C: URL) <br/> the URL/Rewrite-status will be rewritten to/test/status /. </P> <p> the above rule and this outbound-rule means that end users shold never see the <br/> URL/Rewrite-status only/test/status/both in thier location bar and in hyperlinks <br/> in your pages. <br/> </Note> <br/> <from>/Rewrite-status </from> <br/> <to>/test/status/</to> <br/> </outbound-Rule> <br/> </urlrewrite> <br/>
Rule is the URL rewriting rule, from is the displayed address, to is the actual address of the ing, $1 is the rewriting parameter, can be multiple, () is the matching regular expression.
Now, create world. jsp in the project, start Tomcat, and enter
Http: // localhost: 8080/mysite/World/1
Mysite is your project name
What is actually accessed is http: // localhost: 8080/mysite/World. jsp? Tid = 1
In this way, the pseudo-static effect is implemented simply.
When purchasing a space, if your space requires pseudo-static support, please be sure to ask whether it supports pseudo-static, or activate pseudo-static for free. To avoid being fooled!