Struts2整合Spring的两种方式(最新)

来源:互联网 发布:三菱plc3u编程手册 编辑:程序博客网 时间:2024/04/25 17:58

方式一只需要在项目中引入struts2-spring-plugin-2.2.1.1.jar这个Jar包就可以了。这个Jar包引入之后确保web.xml中加载了spring配置,否则会报空指针异常(原因是方式一会自动在spring配置文件中找action依赖的service,只需要在action定义需要的service属性,并提供setter方法。就可以自动按名称也就是bean的id将spring工厂中配置的service注入到action中去,而action的配置中并不需要将property配置)


具体介绍如下:






原创粉丝点击