I do have a question regarding annotation for Struts2-Spring plugin. I want my action classes to be annotated.
How could we map the class attribute of action element in struts.xml to id attribute of bean element in applicationContext.xml?
srtuts.xml
applicationContext.xml
If I'm going to look at the org.apache.struts2.convention.annotation.Action interface, the only properties there are
value
results
interceptorRefs
params
exceptionMappings
And what I'm planning to do is move my entries inside my struts.xml to annotations in my action classes but the thing is I could not map the class attribute of action element(struts.xml) to the id attribute of bean element (applicationContext.xml)
Do you have suggestions on how I could make my action classes annotated?
If you're not using a Struts 2 XML config file there's no mapping required, because there's no Struts 2 XML to map to.
Paul Michael Serrano
Ranch Hand
Joined: Nov 22, 2004
Posts: 59
posted
0
Hi Dave,
Currently we do have struts.xml in our application and it is being shared accross the application (some of the entries are not mine).
So I removed this in my struts.xml:
I tried to putting some of the entries in our struts.xml into annotations, after that our codes look like this one:
After that, we decided to put Spring into our application and downloaded the Struts2-Spring plugin. I tried to follow the documentation of for using the plugin:
http://struts.apache.org/2.x/docs/spring-plugin.html and ended up on going back to the struts.xml config.
struts.xml
and applicationContext.xml
How could I make use of the convention plugin for Struts2-Spring plugin, so that I will not make an entry for struts.xml? Do you have any site or document to look at for this topic?
You already *were* using the Convention plugin, no? Which annotations were you using?
In any case, once you're using the Spring plugin, actions are instantiated through Spring, and as such, can be auto-wired, annotated, etc. like any other Spring bean.
Puneet Babbar
Greenhorn
Joined: Jul 11, 2011
Posts: 1
posted
0
Hey i am facing the same trouble - have to add spring support to my struts 2 application and i have no clue, as to how will be using a bean created from the action class to be read by the struts 2 framework as the action class.
Since i am using convention plugin and i dont have a struts.xml file in my application, where will i specify this? I can do the same thing using struts.xml but haven't been able to find any way to do it without this file.
Were you able to find the approach to solve this issue?