Struts结合Spring有两种方法
1.在Struts的配置文件中用<plug-in>
2.在web.xml中加入
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>当我用第二种方案的时候,加入
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> 当我用地一种方案加入的时候,就错了。。有什么解决方案不
1.在Struts的配置文件中用<plug-in>
2.在web.xml中加入
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>当我用第二种方案的时候,加入
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> 当我用地一种方案加入的时候,就错了。。有什么解决方案不
<param-name>contextConfigLocation </param-name>
<param-value>classpath*:applicationContext-*.xml </param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
</listener> <filter>
<filter-name>hibernateFilter </filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter </filter-name>
<url-pattern>/* </url-pattern>
</filter-mapping> 正常都这么配置啊 <plug-in> 还一直没用过呢!
在web.xml里通过配置Context-param来注册Spring的环境,这样在WebServer启动时就会加载
而在struts-config.xml中注册Spring,可能得先加载Struts以后才加载Spring
这样配置OpensessionInViewFilter可能会有错吧?
不知楼主说出错是什么错啊?
这样在WebServer一启动就会认识Spring的存在,
然后用到它的一些组建的话可能也不容易出粗!
那只是通过插件的方式去注入相应的类,起到的作用和写监听器是一样的,今天有事忙就不在这里多写了,有意向了解更多信息的加我QQ260990509
<param-name>contextConfigLocation </param-name>
<param-value>classpath*:applicationContext-*.xml </param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>就不需要了吧?tomcat能正常启动到页面上老是 no ContextLoaderListener registered错误<plug-in>路径classpath*:applicationContext-*.xml?要不要*?
plug-in用的很少啊,为什么你不用最通用的做法呢?