简体   繁体   中英

Urlrewrite and struts actions

I am using struts 1 and urlwrite (http://www.tuckey.org/urlrewrite/), and I have the following problem. I want to change the url of an action, and when that new url is called the action should be executed. For doing this is wrote the following configuration in the urlrewrite.xml:

<rule>
    <from>/users/create</from>
    <to>%{context-path}/createUserAction\.do</to>
</rule>

<outbound-rule >    
    <from>/createUserAction\.do</from>
    <to>/users/create</to>      
</outbound-rule>

Then the html:link to prepareCreateUserAction, is changed to /users/create. But, then it uses the rule abve, but it tries to redirect the the action name without the .do ( http://localhost:8008/myapp/createUserAction instead of http://localhost:8008/myapp/createUserAction.do ), and no action is found.

Does anyone knows how to solve this?

It looks like for those rules, the <to> doesn't use regular expressions, so the first rule should actually be:

<rule>
    <from>/users/create</from>
    <to>%{context-path}/createUserAction.do</to>
</rule>

In other words, remove the \\ from before the .do

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