我正在使用urlrewriter重写url,如下所示:
<rule>
<from>^/([a-zA-Z\-]+)/</from>
<to>/index.jsp?category=$1</to>
</rule>所以如果我点击一个像这样的http://localhost:8080/website/categoryname/链接,它实际上会转到网页http://localhost:8080/website/index.jsp?category=categoryname。
我遇到的问题是,如果我首先单击category1的链接,它会正确地将URL重写为http://localhost:8080/website/category1/。
但当我在category1网页上点击category2的链接时,它会附加到现有的重写网址上,就像这样:http://localhost:8080/website/category1/category2/。
它应该看起来像这样的http://localhost:8080/website/category2/。
这是我的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>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>为什么它不能正确重写?
发布于 2014-06-06 18:19:43
为了解决这个问题,我必须删除网页链接和规则的from部分中的最后一个正斜杠/。
<rule>
<from>^/([a-zA-Z\-]+)$</from>
<to>/index.jsp?category=$1</to>
</rule>https://stackoverflow.com/questions/24078964
复制相似问题