Web项目中加载Spring配置的常用方法
2015-10-28 16:00
686 查看
1、web.xml中添加配置
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
<!--<param-value>classpath*:applicationContext-*.xml</param-value>-->
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
2、web.xml中添加配置
<web-app>
<context-param>
<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>
</web-app>
3、在(struts-config.xml)中加载
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml,
/WEB-INF/action-servlet.xml"/>
</plug-in>
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
<!--<param-value>classpath*:applicationContext-*.xml</param-value>-->
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
2、web.xml中添加配置
<web-app>
<context-param>
<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>
</web-app>
3、在(struts-config.xml)中加载
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml,
/WEB-INF/action-servlet.xml"/>
</plug-in>
相关文章推荐
- Spring IoC实现解耦合
- Java中的final用法及含义
- MyEclipse + Maven开发Web工程的详细配置过程
- Java String常量字符串理解
- java在线接口文档
- js与java正则表达式处理字符串问题
- project facet java version 1.8 is not
- Mac OS X 中安装JDK 7
- 菜鸟的java学习-------第一篇初识java
- 使用 Google Guava 美化你的 Java 代码:1~4
- 关于java.lang.IllegalMonitorStateException
- java清理对象的时候“=null”与“gc”的比较
- JAVA笔记-如何将百万级数据高效的导出到Excel表单
- java清理对象的时候“=null”与“gc”的比较
- Spring随笔3
- eclipse使用git
- Eclipse package,source folder,folder区别及相互转换
- Eclipse中SVN过滤指定文件夹或文件下内容
- Struts 2 接收post请求
- 使用Spring MVC 的 @RequestBody 映射json请求参数时报异常问题