0
点赞
收藏
分享

微信扫一扫

web.xml

一叶轻舟okok 2022-01-22 阅读 52
spring

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">


        <!--Spring是父容器,SpringMVC是其子容器,
        并且在Spring父容器中注册的Bean对于SpringMVC容器中是可见的,
        而在SpringMVC容器中注册的Bean对于Spring父容器中是不可见的,
        即:子容器可以看见父容器中的注册的Bean.-->

    <!-- servletContext[JVM上的每个webapp都会有一个servletContext对象]
    context-param是给servletContext对象传值的。
    该sc对象方法有:sc.getAttributeNames();sc.getAttribute(name);sc.removeAttribute(name);
    3.0之后又增加了一些方法如:sc.create[Web对象]()和·······sc.add[web对象]()
    通过这个ServletContextListener来启动业务层模块的spring容器。所有监听器同步工作。-->
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:/spring/dispatcher-servlet*.xml</param-value>
        </context-param>
        <listener>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>
        </listener>

        <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <description>springmvc上下文初始化需要的配置文件所在位置</description>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:spring/dispatcher-servlet.xml</param-value>
            </init-param>
            <!--我们让这个DispatcherServlet 最先加载-->
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>

</web-app>

举报

相关推荐

web.xml参考

web.xml介绍

Web.xml详解

web.xml配置

如何配置web.xml

web.xml最新配置

0 条评论