`

web.xml配置加载spring

阅读更多
web.xml配置加载spring


第一种加载applicationContext.xml的方法:
1.默认是这个路径(可以不写):
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

2.其他路径(一定要写):
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath*:spring/core/applicationContext.xml</param-value>
</context-param>

 

<listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>

<context-param>是可选项,如果没有的话就加载applicationContext.xml,也可以用它指定其他配置文件。



第二种加载applicationContext.xml的方法:
 <servlet>  
    <servlet-name>context</servlet-name>  
    <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>  
    <load-on-startup>1</load-on-startup>  
</servlet>















分享到:
评论

相关推荐

    项目配置文件( spring-mvc.xml spring-mybatis.xml web.xml log4j.properties)

    spring-mvc.xml spring-mybatis.xml web.xml log4j.properties,项目中需要用到的配置文件。直接可用。

    加载spring 文件,在web.xml中的配置

    加载spring 文件,在web.xml中的配置

    web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序

    java servlet spring web filter listenr

    web.xml中如何设置配置文件的加载路径实例详解

    web应用程序通过Tomcat等容器启动时,会首先加载web.xml文件,通常我们工程中的各种配置文件,如日志、数据库、spring的文件等都在此时被加载,下面是两种常用的配置文件加载路径,即配置文件可以放到 SRC目录下或者...

    DWR.xml配置文件说明书(含源码)

    DWR.xml配置文件说明书 1、 建立dwr.xml 配置文件 任何一个dwr.xml的文件都需要包含DWR DOCTYPE的声明行,格式如下: &lt;!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" ...

    spring MVC 配置文档

    加载 DispatcherServlet 时 Spring 会尝试读取配置文件 默认的配置文件位于 web.xml 相同的路径下 文件名与注册的 Servlet 名有关 Servlet注册名跟上 -servlet.xml 例如:上面的 Servlet 注册名为 ...

    CXF发布WebService的多种方法实例

    3、web.xml里配置spring监听器,及其加载的beans.xml,把cxf-servlet.xml删掉,发布到WEB服务器即可,注意这种方式在必须需要本地wsdl文件 手动放在src下,默认发布到web服务器的路径为WEB-INF/classes/xxx.wsdl ...

    logback-ext-spring

    spring使用logback的扩展,使用起来非常方便。在web.xml中配置: ... &lt;listener-class&gt;ch.qos.logback.ext.spring.web.LogbackConfigListener &lt;/listener&gt; 即可加载logback配置,使用logback。

    springweb3.0MVC注解(附实例)

    -- Spring MVC 的Servlet,它将加载WEB-INF/annomvc-servlet.xml 的 配置文件, 以启动Spring MVC模块--&gt; &lt;servlet-name&gt;annomvc org.springframework.web.servlet.DispatcherServlet &lt;load-on-startup&gt;2 ...

    JavaWeb中web.xml初始化加载顺序详解

    本篇文章主要介绍了JavaWeb中web.xml初始化加载顺序详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    springboot mybatis springmvc整合实例.docx

    作为常规的来说,一个ssm框架整合,拿maven来说,首先在src/main/resource下加入jdbc.properties,spring- mvc.xml,spring-mybatis.xml等,还有要再web.xml配置监听类和前端控制器,同时还要配置对应的加载spring- ...

    shiro资料一览

    一,添加struts2的支持 1.添加jar包 struts-2.3.4.1\apps\struts2-blank\WEB-INF\lib 2.添加配置文件 struts-2.3.4.1\apps\struts2-...3.在web.xml中添加context-param指定spring配置文件的位置,并通过监听器加载

    在Spring Boot中加载XML配置的完整步骤

    主要给大家介绍了关于在Spring Boot中加载XML配置的完整步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

    spring boot2.0以上版本整合mybatis+pagehelper+druid

    1)配置 web.xml,加载 Spring 和 Spring mvc 2)配置数据库连接、配置 Spring 事务 3)配置加载配置文件的读取,开启注解 4)配置日志文件 … n) 配置完成之后部署 tomcat 调试 可能你还需要考虑各个版本的...

    JAVA Spring框架实现登陆查询 完整搭建框架方法的word文档 包含mysql文件

    2 配置加载spring-mybatis.xml 3 配置编码过滤器 4 配置加载sping-mybaties文件所需要的类 5 配置处理javabean类销毁的类 6 配置sping-mvc的前端控制器 7 配置 项目默认访问页面和设置session的会话...

    springboot参考指南

    从Spring配置分离@Entity定义 v. 67.5. 配置JPA属性 vi. 67.6. 使用自定义的EntityManagerFactory vii. 67.7. 使用两个EntityManagers viii. 67.8. 使用普通的persistence.xml ix. 67.9. 使用Spring Data JPA和...

    spring学习笔记

    ..............................................................................................................9 1.3.7Spring 框架加载配置文件:..............................................................

    struts1.2+spring2.0+hibernate3.1框架整合实例

    采用在web.xml中加载spring配置文件的方法降低struts和spring的耦合度,使用自定义的MyDelegatingRequestProcessor类来代替spring的DelegatingRequestProcessor类来解决spring中action的bean的重复配置问题。...

    CXF WebService整合Spring示例工程代码demo

    -- 设置Spring容器加载配置文件路径 --&gt; &lt;param-name&gt;contextConfigLocation &lt;param-value&gt;classpath*:applicationContext-server.xml &lt;listener-class&gt;org.springframework.web.util....

    BOS技术整理-05

    将cxf配置在web.xml中 与applicationContext.xml中声明服务的bean 创建一个maven项目(war) 编写实体类,Service 导入applicationContext.xml 配置cxf的发布 客户端测试代码 WebService-RS ...

Global site tag (gtag.js) - Google Analytics