struts2struts1

Can Struts1 and Struts2 can have same url extension (*.do) in one application?


We can have both Struts1 and 2 in one application. I have more than 100 URL's defined in struts1 and I am migrating those URL's to Struts2.

Suppose say my URL's be like,

1. something1.do
2. something2.do
....
100. something100.do

And from the above URL's I want to configure some URL's in Struts2.

Therefore my question is can we configure some set of URL's having extension of (.do in struts1 and some set of URL's in Struts2.


Solution

  • Yes, you can, but it will introduce complexities if you must maintain existing URLs.

    If you're unable to change the pattern of the Struts 1 URLs, and cannot prefix either with a unique namespace, you'll need to serve Struts 2 static resources from the filesystem instead of letting S2 handle it. If you can modify S1 URLs then it's straight-forward by changing the S1 servlet mapping.

    Another option is to use a filter or S2 interceptor to map known S1 mappings to a different namespace in the S1 app. This requires some minor web.xml modifications if you want to display the old S1 URL.

    It would be cleaner, and easier, to use different extensions. There are no fundamental issues in mixing the two frameworks in the same app. When you're linking from an S1 page to an S2 action you'll need to build the URL manually since the taglibs are unaware of each other.