日期:2014-05-17  浏览次数:20702 次

关于JSP页面url加密或伪装的问题
SSH做的简单的留言系统中有如下地址
http://localhost:8888/yqia/findDetail.action?ID=16
如果有人直接在地址栏输入id,就可以直接到指定的页面
我想把后面的ID隐藏掉,或者加密成其他字符串,用UrlRewriteFilter可以实现么?或者有什么其他的方法可以对url进行加密
我用UrlRewriteFilter实现的方法是:
在urlrewrite.xml配置文件中添加规则:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
  "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
<!--
  Configuration file for UrlRewriteFilter
  http://tuckey.org/urlrewrite/
-->
<urlrewrite>

<rule>
<from>/yqia/([0-9]+).html</from>
<to>/../yqia/findDetail.action?ID=</to>
</rule>

</urlrewrite>

web.xml中配置如下:
<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> 
</filter-mapping>
可是还是实现不了,不知道是不是有什么配置没有配好,我的那个通过ID查找的JSP代码是:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>问题库管理</title>
<link type="text/css" rel="stylesheet"
href="${pageContext.request.contextPath}/admin/css/css.css"></link>
<script type="text/javascript" charset="utf-8"
src="${pageContext.request.contextPath}/admin/js/checkbox.js"></script>
</head>

<body onload="getCheckboxNum()">
<jsp:include page="head.jsp"></jsp:include>
<br />
<div class=gTitle>
<B class=mTT>问题库</B>&nbsp;&nbsp;(共&nbsp;
<B id=oTotal>${questionNum[0]}</B>&nbsp;个问题,其中&nbsp;
<A title="" href="findRespondQuestion.action">已解决</A>&nbsp;&nbsp;
<B class="" id=oTotalUnRead>${questionNum[2]}</B>&nbsp;&nbsp;个,
<A title="" href="findUnRespondQuestion.action">待解决</A>&nbsp;&nbsp;
<B class="fnt_Red" id=oTotalUnRead>${questionNum[1]}</B>&nbsp;&nbsp;个)
</DIV>
<form name="checkboxform" action="#" method="post">
<table id="table" cellspacing="0 ">
<tr>
<th width="15" scope="col">
&nbsp;
</th>
<th width="96" scope="col">
提问者
</th>
<th width="15" scope="col"></th>
<th width="329" scope="col">
标题
</th>
<th width="202" scope="col">
提问时间
</th>
<th width="140" scope="col">
操作
</th>
</tr>
<c:forEach items="${questionList}" var="question" varStatus="st