jsp中url重写实例
2007-11-30 23:23
302 查看
1.在web.xml中配置一个过滤器
<filter>
<filter-name>testfilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>//此包需要下载
</filter>
<filter-mapping>
<filter-name>testfilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.新建一个urlrewrite.xml文件 与web.xml放在一起 配置如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
"http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
<!--
Configuration file for UrlRewriteFilter
http://tuckey.org/urlrewrite/
-->
<urlrewrite>
<rule>
<from>index.html</from> //随便命名的
<to >/index.jsp</to> //源文件
</rule>
<rule>
<from>(/d*).php</from> //地址栏中显示的 (/d*) 表示所有数字
<to >/jsp1.jsp?id=$1</to> //源文件 传参数
</rule>
</urlrewrite>
3.测试页面
<html>
<head>
<title>
index
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<a href="jsp1.html">asdfasfasd</a>
<%
for(int i=10;i<100;i++)
{
out.print("<a href="+i+".php>");
out.print(i+i+i);
out.print("</a><br>");
}
%>
</body>
</html>
jsp1.jsp页面
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
jsp1
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<a href="index.html">index</a>
<%=request.getParameter("id") %>
</h1>
</body>
</html>
<filter>
<filter-name>testfilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>//此包需要下载
</filter>
<filter-mapping>
<filter-name>testfilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.新建一个urlrewrite.xml文件 与web.xml放在一起 配置如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
"http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
<!--
Configuration file for UrlRewriteFilter
http://tuckey.org/urlrewrite/
-->
<urlrewrite>
<rule>
<from>index.html</from> //随便命名的
<to >/index.jsp</to> //源文件
</rule>
<rule>
<from>(/d*).php</from> //地址栏中显示的 (/d*) 表示所有数字
<to >/jsp1.jsp?id=$1</to> //源文件 传参数
</rule>
</urlrewrite>
3.测试页面
<html>
<head>
<title>
index
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>
<a href="jsp1.html">asdfasfasd</a>
<%
for(int i=10;i<100;i++)
{
out.print("<a href="+i+".php>");
out.print(i+i+i);
out.print("</a><br>");
}
%>
</body>
</html>
jsp1.jsp页面
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
jsp1
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<a href="index.html">index</a>
<%=request.getParameter("id") %>
</h1>
</body>
</html>
相关文章推荐
- 实例详解JSP内置对象
- JSP简单练习-包装类综合应用实例
- Tomcat+JSP经典配置实例
- jsp中实现带滚动条的table表格实例代码
- Struts2 验证码图片生成实例 (用.jsp产生验证码)
- jsp连接mysql实例(bean)
- Tomcat+JSP经典配置实例
- 实例讲解:全程追踪入侵JSP网站服务器
- jsp+javascript打造级连菜单的实例代码
- jsp中调用oracle存储过程的实例
- JSP 入门实例 及tomcat部署
- JSP_<jsp:application>实例
- FCKedit jsp版本的安装与配置(实例源码下载)
- jsp连接Access实现对Access的增删改查实例源码
- 《基于BootStrap3的JSP项目实例教程》第2讲
- jsp页面中的session、cookies、隐藏域、url重写四种会话及跟踪方式
- Fckeditor jsp使用实例,自定义Fckeditor的工具栏
- JSP文件上传程序实例
- JSP自定义标签rtexprvalue属性用法实例分析
- JSP详解与实例