115893520 写道
url重写
加入urlrewrite.xml在WEB-INF目录下
加入urlrewrite-2.6.0.jar 包
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>/space/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/board/*</url-pattern>
</filter-mapping>
urlrewrite.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>^/space/([0-9]*)$</from>
<to>/space.jsp?mid=$1</to>
</rule>
<rule>
<from>^/board/([a-zA-Z]+)/$</from>
<to>/board/$1/index.jsp</to>
</rule>
<rule>
<from>^/board/([a-zA-Z]+)/topic/([0-9]+)([^\n]*)$</from>
<to>/board/$1/topic.jsp?id=$2</to>
</rule>
<rule>
<from>^/space/([0-9]+)/weblogs/([0-9]+)([^\n]*)$</from>
<to>/diary/showdiary.jsp?mid=$1&id=$2</to>
</rule>
<rule>
<from>^/space/([0-9]+)/weblogs([^\n]*)$</from>
<to>/diary/listdiary.jsp?mid=$1</to>
</rule>
<rule>
<from>^/space/([0-9]+)/photos/gallery/([0-9]+)/([0-9]+)([^\n]*)$</from>
<to>/album/photosview.jsp?mid=$1&albumid=$2&photoid=$3</to>
</rule>
<rule>
<from>^/space/([0-9]+)/photos/gallery/([0-9]+)([^\n]*)$</from>
<to>/album/photolist.jsp?mid=$1&albumid=$2</to>
</rule>
<rule>
<from>^/space/([0-9]+)/photos([^\n]*)$</from>
<to>/album/myalbum.jsp?mid=$1</to>
</rule>
<rule>
<from>^/space/([0-9]+)/share([^\n]*)$</from>
<to>/info/recomlist.jsp?mid=$1</to>
</rule>
<rule>
<from>^/space/([0-9]+)/friends/dynamic([^\n]*)$</from>
<to>/info/friend_1.jsp?mid=$1</to>
</rule>
<rule>
<from>^/space/([0-9]+)/friends/list([^\n]*)$</from>
<to>/info/friend_2.jsp?mid=$1</to>
</rule>
<rule>
<from>^/space/([0-9]+)/profile([^\n]*)$</from>
<to>/info/info_1.jsp?mid=$1</to>
</rule>
</urlrewrite>
^/space/([0-9]*)$
/space.jsp?mid=$1
这样写会有问题吧。我感觉最好把space.jsp也放到真实的space目录下,要不会有些图片什么 的相对连接出问题的