JSP pseudo-static instance tutorial

Source: Internet
Author: User

SP pseudo-static is no different from the pseudo-static of other programs. It feels like iis needs the support of a component. We need to use urlrewrite to support JSP pseudo-static.


1. Download urlrewrite
Http://tuckey.org/urlrewrite/

2. Put the downloaded jar to our app's/WEB-INF/lib/urlrewritefilter-4.0.3.jar

3. Add the following code in WEB-INF/web. xml
 

The Code is as follows: Copy code

<Filter>
<Filter-name> UrlRewriteFilter </filter-name>
<Filter-class> org. tuckey. web. filters. urlrewrite. UrlRewriteFilter </filter-class>
</Filter>
<Filter-mapping>
<Filter-name> UrlRewriteFilter </filter-name>
<Url-pattern>/* </url-pattern>
<Dispatcher> REQUEST </dispatcher>
<Dispatcher> FORWARD </dispatcher>
</Filter-mapping>


4. Create urlrewrite. xml in/WEB-INF/urlrewrite. xml
The urlrewrite. xml file is used to describe pseudo-static redirection rules.

 

The Code is as follows: Copy code
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE urlrewrite PUBLIC "-// tuckey.org//DTD UrlRewrite 4.0 // EN"
Http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd>
<Urlrewrite>
<! -- Configuration without parameters -->
<Rule>
<Note>
This rule indicates that/index.html will be redirected to/Index. jsp
</Note>
<From>/index.html </from>
<To type = "forward">/Index. jsp </to>
</Rule>
<! -- Configuration with a parameter -->
<Rule>
<Note>
This rule indicates that the/index-1.html will be redirected to/Index. jsp? P1 = 1
</Note>
<From>/index-(w * pai.html </from>
<To type = "forward">/Index. jsp? Id = $1 </to>
</Rule>
<! -- Configuration of multiple parameters -->
<Rule>
<Note>
This rule indicates that the/index-1-1.html will be redirected to/Index. jsp? P1 = 1 & p2 = 1
</Note>
<From>/index-(w *)-(w * example .html </from>
<To type = "forward">/Index. jsp? P1 = $1 & amp; p2 = $2 </to>
</Rule>
</Urlrewrite>


In this way, you can check the effect after restarting the container (tomcat ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.