We are using Struts 2 + Spring 4 and we want to setup the spring to manage our struts 2 actions.
The spring beans are defined by annotations.
The struts actions are located with convention plugin, so we do not have any actions in the struts.xml
files.
The actions are as below:
//It is located in action folder so it will be located by convention plugin
package foo.bar.actions.usermanager
@Named //This will be used by Spring to located and manage this Bean
public class EditUser(){
@Action(className="editUser") // Should I defined class name here ?!
public String execute() {
}
}
The above code works. But I looking to find if there are better ways, so we can omit the className (which is exactly camel conversion of action name)
Is it possible?!
By default the className
attribute contains the name of the class in which the action is found by the convention plugin when creating the action config from the annotation. It's not required if you build an ordinary Struts action config. But in conjunction with spring plugin if you want to delegate the building and managing actions to Spring you have to provide such attribute. It's the same as class
in the xml based action config and such names used by convention with spring plugin. See Initializing Action from Spring and Alternative - Have Spring Manage Creation Of ActionSupport
Class related docs.