简体   繁体   中英

tuckey urlrewrite not working for query variable in url-rewrite

I am using tuckey urlrewrite filter for clean url in JSF on Glassfish. Following is the rule of the filter (which is not working):

    <rule>
        <from>^/user/(.*)$</from>
        <to>%{context-path}/faces/testUser.xhtml?username=$1</to>
    </rule>

I am getting HTTP-404, The requested resource () is not available.

The filter works when I give "to" tag as follows (ie type=redirect):

   <to type="redirect">%{context-path}/faces/testUser.xhtml?username=$1</to>

another rule is working just fine for forward:

    <rule> 
        <from>/home</from>
        <to>faces/index.xhtml</to>
    </rule>

following is the filter configuration in 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>

any idea, how to work it out?

when I changed rule as follows, it is working fine:

    <rule>
        <from>^/user/(.*)$</from>
        <to>/faces/testUser.xhtml?username=$1</to>
    </rule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM