gpt4 book ai didi

java - tuckey urlrewrite 不适用于 url 重写中的查询变量

转载 作者:行者123 更新时间:2023-12-01 14:15:21 32 4
gpt4 key购买 nike

我在 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com