<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>
<servlet>
<servlet-name> SpringContextServlet </servlet-name>
<servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
加有一个就可以了 它是不同的的servlet版本中启动spring容器的 作用都一样
<listener-class> org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>
<servlet>
<servlet-name> SpringContextServlet </servlet-name>
<servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
加有一个就可以了 它是不同的的servlet版本中启动spring容器的 作用都一样
解决方案 »
- 做j2ee开发的请过来帮帮忙
- 这个图是用什么工具画的?
- 全文检索
- distinct和order by可以同时使用么?怎么用?
- 给初学者提供一个《Spring & Hibernate框架入门教程》
- 如何理解容器的概念
- Hibernate DAO 类如何执行:select SC_PRODUCTION_IDX.nextval from dual
- 调用很简单的存储过程,失败!为什么?
- java中有没有截尾函数呀???例如取整或四舍五入
- 有经验的大大请进来看下。。。
- 运行EJB客户端出现的问题.Exception in thread "main" java.lang.NoClassDefFoundError
- 高手门求救啊!JBuilder2006,由于我卸载从装的原因~现在装上运行不起来。高分求!
<param-name> contextConfigLocation </param-name>
<param-value> /WEB-INF/applicationContext.xml </param-value>
</context-param>
<servlet>
<servlet-name> SpringContextServlet </servlet-name>
<servlet-class> org.springframework.web.context.ContextLoaderServlet </servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
这个增加后,还需要在struts-config.xml文件中增加如下的插件??
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
</plug-in>
这两者有都要加?只能加一个?什么时候要配置哪一个?或哪一个是必须的? 上面的这几部分是必须要加的
1.指明配置参数,这个很好理解吧,不配置就找不到spring的配置文件了。不过这个配置好像有默认值。
2.指明监听器,这种方法我是没有使用过,一般使用listener这种方式,估计你可以二选一。
3.这个是指明struts的action被spring代理管理起来了,简单说就是struts的action对象被管理在spring的bean中了。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/spring-config.xml</param-value>
</context-param>
是必须的~~~~
其他的根据情况来自己配置配置一,楼主写的那种方式;配置二,不用spring提供的servlet:<!-- contextConfigLocation 属性代表spring-config.xml文件的地址-->
<context-param>
<description>Spring2.0 Config</description>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/spring-config.xml</param-value>
</context-param>
<!-- log4jConfigLocation 属性代表log4j.properties文件的地址-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/config/log4j.properties</param-value>
</context-param>
<!-- 加上这个Spring的Log4j侦听类,注意在JBOSS里面,不需要这个类,注释掉,不然会冲突 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- 加上这个Spring的侦听类 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>其他的地方按照struts配置不变。