我在 Glassfish 上的 JSF 中使用 tuckey urlrewrite 过滤器来清理 url。 以下是过滤器的规则(不起作用):
<rule>
<from>^/user/(.*)$</from>
<to>%{context-path}/faces/testUser.xhtml?username=$1</to>
</rule>
我收到 HTTP-404,请求的资源 () 不可用。
当我按如下方式给出“to”标签(即 type=redirect)时,过滤器就会起作用:
<to type="redirect">%{context-path}/faces/testUser.xhtml?username=$1</to>
另一个规则对于转发来说效果很好:
<rule>
<from>/home</from>
<to>faces/index.xhtml</to>
</rule>
以下是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>
有什么想法吗?如何解决?
最佳答案
当我按如下方式更改规则时,它工作正常:
<rule>
<from>^/user/(.*)$</from>
<to>/faces/testUser.xhtml?username=$1</to>
</rule>
关于java - tuckey urlrewrite 不适用于 url 重写中的查询变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18154872/