美文网首页
struts 自动将 Action 类中的属性装载为 bean

struts 自动将 Action 类中的属性装载为 bean

作者: 风亡小窝 | 来源:发表于2017-09-13 17:52 被阅读2次

在ssh整合项目中,由于 struts 框架使用 spring-plugin ,当struts初始化时,struts 会自动装载 Action 类中属性(即 setXxx() 方法)。

例如:

public class TestAction {
    
    private AccountService service;

    public AccountService getService() {
        return service;
    }

    public void setService(AccountService service) {
        this.service = service;
    }
    
}

struts会把TestAction中的属性类型AccountService作为Spring bean装载。

牢记: struts为Action自动装载的属性的bean idsetXxx, getXxx中的xxx(首字母转为小写)。

即使属性名为如下,beanid也是service

public class TestAction {
    
    private AccountService service111111;

    public AccountService getService() {
        return service;
    }

    public void setService(AccountService service) {
        this.service = service;
    }
    
}

相关文章

网友评论

      本文标题:struts 自动将 Action 类中的属性装载为 bean

      本文链接:https://www.haomeiwen.com/subject/qnrlsxtx.html