实现jsp网站伪静态(URL Rewrite实现)

1、www.tuckey.org/urlrewrite/ 下载URL Rewrite JAR包

2、将jar包复制到项目WEB-INF/web.xml

3、在web.xml中配置URL Rewrite,代码如下:

<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、添加伪静态映射规则urlrewrite.xml

<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
	"http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
<urlrewrite>
	<rule>
		<!-- 所有配置如下正则表达式的请求 -->
		<from>/hellotag.html</from>
		<!-- 将被forward到如下JSP页面,其中$1代表
			上面第一个正则表达式所匹配的字符串 -->
		<to type="forward">/hellotag.jsp</to>
	</rule>
</urlrewrite>


 

 

你可能感兴趣的:(jsp,伪静态)