改变JSP的文件后缀

发表于:2007-07-04来源:作者:点击数: 标签:

首先,在WEB.XM里配置
<servlet>
<servlet-name>testsuffix</servlet-name>
<servlet-class>mytest.TestSuffix</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testsuffix</servlet-name>
<url-pattern>*.br</url-pattern>
</servlet-mapping>



在SERVLET里写页面转向就可以啦..
String uri = request.getRequestURI();
uri = uri.replaceFirst(".br", ".jsp");

RequestDispatcher rd = request.getRequestDispatcher(uri);
rd.forward(request, response);



哈哈哈.可以通过*.br访问以前的JSP文件啦.

原文转自:http://www.ltesting.net