user1438547
user1438547

Reputation: 3

Redirect .do URL to a .action URL?

I migrated a struts1 page to struts2 in an application. However, I still need the old page's URL of "/login.do" to be accessible for backwards compatibility.

How can I redirect/map the "login.do" URL to "login.action"?

I believe that this can be accomplished by writing a filter class, but I don't want to do that because it seems too complicated for the task. There has to be a way to do it in web.xml, struts.xml or struts-config.xml.

I'll buy the person with best answer a beer (in Phoenix). :)

Upvotes: 0

Views: 2203

Answers (1)

Dave Newton
Dave Newton

Reputation: 160321

Change the action extension. This is from the default struts.properties:

### Used by the DefaultActionMapper
### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do
### The blank extension allows you to match directory listings as well as pure action names
### without interfering with static resources, which can be specified as an empty string
### prior to a comma e.g. struts.action.extension=, or struts.action.extension=x,y,z,,
struts.action.extension=action,,

XML configuration of constants is preferred, however, so I'd put it in your struts.xml.

It also avoids an actual redirect, although a filter for that is trivial.

Upvotes: 1

Related Questions