ITeye博客

struts 1 与spring 2.5整合要点

mjbb · 2010-03-29 15:07 · spring · 企业架构 · Markdown

struts 1 与spring 2.5整合要点: 在整合中要思考的是:怎样才能实例化spring容器.先把spring容器放到web容器中,然后再根据一些方法去提取 1.在web.xml中配置 ①.加载spring 容器 contextConfigLocation /WEB-INF/classes/beans.xml ②.实例化spring 容器 contextLoader org.springframework.web.context.ContextLoaderServlet 0 org.springframework.web.context.ContextLoaderListener

2.在struts-config.xml中配置 request请求委托给spring 容器

3.在spring容器配置文件中配置,所请求的Action

第二种方案:

只需要以上的第一种方案的第一步,然后可以之间可以在Action的方法中实例化spring 容器: 实例化的时候要知道当前servlet的容器才能实例化spring容器------>这种方式请求可以不用委托给spring 容器了 WebApplicationContext wac= WebApplicationContextUtils. getWebApplicationContext(this.getServlet(). servletContext());

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。