我们正在使用Struts 2 + Spring 4,我们希望设置Spring来管理我们的struts 2操作。
spring beans由注解定义。
struts操作位于约定插件中,因此我们在struts.xml
文件中没有任何操作。
这些行动如下:
//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() {
}
}
字符串
上面的代码工作。但我想看看是否有更好的方法,所以我们可以省略className(这正是camel转换的动作名称)
这可能吗?
1条答案
按热度按时间3pmvbmvn1#
默认情况下,
className
属性包含在从annotation创建action config时convention plugin找到action的class的名称。如果您构建普通的Struts action config,则不需要此属性。但是与spring plugin结合使用时,如果您想将构建和管理操作委托给Spring,则必须提供此属性。它与class
中的基于xml的action config和spring plugin约定使用的此类名称。参见Initializing Action from Spring and Alternative - Have Spring Manage Creation OfActionSupport
Class related docs。