我刚从http://tuckey.org/安装了网址重写过滤器。
我添加了一条规则,为来自特定路径.do
的请求添加/beta
。
<rule>
<from>(.*)/beta/(.*)\?(.*)</from>
<to>$1/beta/$2.do\?$3</to>
</rule>
<rule>
<from>(.*)/beta/(.*)</from>
<to>$1/beta/$2.do</to>
</rule>
规则配置进入状态OK,因此已成功加载。
不幸的是,现在我在日志中看到一个异常堆栈跟踪超过5000个留置权并且似乎陷入了循环。
017-03-08 13:50:15.827 [0.0-8080-1] ERROR JSPException [0966E] Exception trapped when showing Error Page! Filter execution threw an exception
javax.servlet.ServletException: Filter execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:259) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394) ~[urlrewritefilter-4.0.3.jar:4.0.3]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292) ~[tmp7900369758995902766jbossweb.jar:4.2.3.GA (build:
就这样......
答案 0 :(得分:2)
似乎递归循环您的规则,因为目标网址与<from>
子句中的正则表达式匹配。尝试重写regex以仅匹配from
表达式,而不是to
生成的url。即。
<rule>
<from>(.*)/beta/(.*)</from>
<to>$1/beta2/$2.do</to>
</rule>
有关详细信息,请参阅本指南URL Rewriting for Beginners。