首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

拉面初学者笔记——Spring集成Struts2

2012-11-06 
拉面菜鸟笔记——Spring集成Struts2今天做了Spring对Struts2的集成。首先在web.xml里面配置spring的listener:

拉面菜鸟笔记——Spring集成Struts2

今天做了Spring对Struts2的集成。

首先在web.xml里面配置spring的listener:

?

?

 <listener>  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param>  <param-name>contextConfigLocation</param-name>  <param-value>/WEB-INF/config/spring-config/platformContext.xml,/WEB-INF/config/spring-config/beanContext.xml</param-value> </context-param>

?

?这样Spring就可以随着容器的启动而启动。

然后为了是struts的action能指向Spring的bean,需要struts2-spring-plugin-XXX.jar。然后再struts.xml中设置

?

<constant name="struts.objectFactory" value="spring" />

?

?这样就可以把struts拦截的请求叫给spring处理了。

然后就可以在struts的action的class里设置指向spring的bean了。

?

热点排行