我在使用Tuckey URL出站规则时遇到问题。 我们正在使用Tuckey和Struts2。
出站规则:
<outbound-rule>
<from>^/articleList\?category=(\d*)&page=(\d*)(;jsessionid=.*)?$</from>
<to last="true">/list/$1/$2</to>
</outbound-rule>
JSP:
<a href="<s:url value="/articleList" ><s:param name="category"
value="#article.category" /><s:param name="page" value="1" /></s:url>" target="_blank[articlelist]</a>
虽然它说处理出站规则但它没有转发到我的URL。
在url-rewritestatus
中,它显示了我的所有规则,但未显示匹配的规则。
调试日志:
org.tuckey.web.filters.urlrewrite.UrlRewriter DEBUG: processing outbound url for /articleList?category=3&page=1
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Outbound Rule 0 run called with /articleList?category=3&page=1
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Outbound Rule 1 run called with /articleList?category=3&page=1
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Outbound Rule 2 run called with /articleList?category=3&page=1
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Outbound Rule 3 run called with /articleList?category=3&page=1
org.tuckey.web.filters.urlrewrite.RuleBase DEBUG: Outbound Rule 4 run called with /articleList?category=3&page=1
调查我看到的来源
url:/articleList?category=1&page=1
pattern:^/articleList\?category=(\d*)&page=(\d*)(;jsessionid=.*)?$
我做错了什么?
EVN:struts2 + spring3 jetty
答案 0 :(得分:0)
您已在网址中转义了&
符号,并在源代码中看到它是&
。这不允许模式匹配url。尝试更改模式以匹配转义和未转义的&符号。
<from>^/articleList\?category=(\d*)(\&|&){1}page=(\d*)(;jsessionid=.*)?$</from>