This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Is there a different way to configuring actions in struts2?  RSS feed

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have requirement to migrate legacy(Struts1.0) code to Struts2. If there are multiple methods in same action class, can we configure them in single action tag?


Here, I have single action i.e. "product" and single action class i.e. "ProductAction". So, can I configure both the methods (show,showErr) in single action tag?
Posts: 14
Chrome IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally I would consider Struts to be legacy and I would migrate to using Spring as soon as you can.

If you use the latest Spring boot for example, you can do away with all those nasty XML files which are cumbersome at best.  Then you can start to use annotations for all you configuration, dependency injection etc.

Just my oppinion though
Posts: 9521
Linux Mac OS X Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Baz Edwards wrote:Personally I would consider Struts to be legacy

Struts 2.5 is under active development, so I wouldn't call it "legacy".  Struts certainly isn't as popular as it used to be.

Baz Edwards wrote:
If you use the latest Spring boot

Spring Boot is a totally different animal.  It is a stand-alone application server and framework in one.  Struts is more akin to Spring MVC alone.  If one just needs a front controller, Struts will work just fine.  Struts can also be configured to use Spring to inject code into Struts actions, so they aren't necessarily exclusive.
I actually prefer XML configuration files to annotations as it is easier to find the configuration information in one place, rather than hunting around in Java source code. 

As for Abhishek's question, no, you cannot configure one action tag to correspond to multiple methods.  The purpose of the action tag is to map a particular web request to a particular method, so that wouldn't make sense. 
If you are looking to avoid writing a ton of XML, look at the Convention Plugin.  It allows one to specify a method name in a particular way and the plugin does the work of the working out the mapping.  It also supports a bunch of annotations to configure the various options available in the action XML tag.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!