java 伪静态

1.复制urlrewrite-3.1.0.jar到lib

2.web.xml配置过滤器

    <!-- 伪静态过滤器注册 -->
  <filter>
     <filter-name>url</filter-name>
     <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  </filter>
 
  <!-- 伪静态过滤器映射-->
  <filter-mapping>
     <filter-name>url</filter-name>
     <url-pattern>/*</url-pattern>
  </filter-mapping>



3. 在WEB-INF中配置规则文件urlrewrite.xml

  <urlrewrite>
   <rule>
      <from>/emp/([0-9]+)/([a-z|A-Z]+).html</from>
      <to>/emp.do?id=$1&amp;name=$2</to>
   </rule>
  
    <rule>
      <from>/emp/([0-9]+)/([a-z|A-Z]+).html</from>
      <to>/emp.do?id=$1&amp;name=$2</to>
   </rule>
</urlrewrite>


你可能感兴趣的:(java,html,Web,xml)