多语言展示
当前在线:1389今日阅读:117今日分享:28

Spring与struts2集成

Spring跟struts2集成:目的: 将spring的ioc容器中的Proxy Object提供给struts2的action使用(注入进Action中).1) 初始化spring的ioc容器(在web.xml中配置) ContextLoaderListener implements ServletContextListener 此监听器负责在整个web应用启动时创建spring的ioc容器.并将spring的ioc容器放入application范围中,以便系统在整个运行过程中一直可以使用.2) 将spring的ioc容器中的Proxy Object注入进action,action中提供setter方法进行注入。 当配置此常量,struts2的Autowiring拦截器就会起作用,负责从spring的ioc容器中找到对应的Proxy Object并调用action的setter方法将Proxy Object注入进action中.
推荐信息