简体   繁体   中英

Struts 2 Multiple URL Extensions

I'm working on a project that's having us replace an old struts 1 application with a new struts 2 application. However, our new Struts 2 application needs to work with many other business applications that expect to call the application with the same URL. So, there will be links such as

businessApplication/view/getById.do?id=XXXXXXXXXX

Our new application uses no suffix (though, you can optionally specify the .action suffix) as opposed to the .do suffix. What I want to do is capture those old URLs (with the .do suffix) and forward to the appropriate action, like:

businessApplication/view/findById?Id=XXXXXXXX

However, I can't find a way to capture anything with the .do suffix. I tried setting the action name to getById.do and getById* to no avail.

Any ideas?

Thanks!

I found my answer in the top answer for this: web.xml filter-mapping not forwarding to struts

This is what I added to my struts.xml

<!-- FOR COMPATIBILITY WITH EXTERNAL APPLICATIONS
This constant allows actions with the suffixes of "", ".action", or ".do".  This allows the creation of actions ending in .do, to allow external applications
that may be looking for .do actions to still use this app without any changes. -->
<constant name="struts.action.extension" value=",action,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