使用spring管理struts动作(由约定插件配置)

4dc9hkyq  于 2024-01-05  发布在  Spring
关注(0)|答案(1)|浏览(115)

我们正在使用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转换的动作名称)
这可能吗?

3pmvbmvn

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 Of ActionSupport Class related docs。

相关问题