web.xml
< filter > < filter-name > OpenSessionInViewFilter </ filter-name > < filter-class > org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </ filter-class > </ filter > < filter-mapping > < filter-name > OpenSessionInViewFilter </ filter-name > < url-pattern > /* </ url-pattern > </ filter-mapping > < listener > < listener-class > org.springframework.web.context.ContextLoaderListener </ listener-class > </ listener >struts-config.xml
< plug-in className ="org.springframework.web.struts.ContextLoaderPlugIn" > < set-property property ="contextConfigLocation" value ="/WEB-INF/applicationContext.xml" /> </ plug-in >此处的org.springframework.web.struts.ContextLoaderPlugIn类里的方法initWebApplicationContext(),在getServletContext().setAttribute(attrName, wac);下增加一条属性设置。 getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
具体原因参考http://www.javaeye.com/topic/15057,里面有很详细的说明