zoukankan      html  css  js  c++  java
  • springmvc下的web.xml的配置

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://java.sun.com/xml/ns/javaee"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     id="WebApp_ID" version="2.5">
    <!--     <display-name>springmvc-web</display-name> -->
    <!--     <welcome-file-list> -->
    <!--         <welcome-file>index.html</welcome-file> -->
    <!--         <welcome-file>index.htm</welcome-file> -->
    <!--         <welcome-file>index.jsp</welcome-file> -->
    <!--         <welcome-file>default.html</welcome-file> -->
    <!--         <welcome-file>default.htm</welcome-file> -->
    <!--         <welcome-file>default.jsp</welcome-file> -->
    <!--     </welcome-file-list> -->
        <!-- 加载spring容器 -->
         <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> 
        
        <!-- DispatcherServlet在web.xml中的配置 -->
        <!-- load-on-startup:表示启动容器时初始化该Servlet;
            url-pattern:表示哪些请求交给Spring Web MVC处理, "/" 是用来定义默认servlet映射的。也可以如"*.html"表示拦截所有以html为扩展名的请求。
             该DispatcherServlet默认使用WebApplicationContext作为上下文,
             Spring默认配置文件为“/WEB-INF/[servlet名字]-servlet.xml”。 -->
        <servlet>
            <servlet-name>springmvc</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
             <init-param>
                <param-name>contextConfigLocation</param-name>
                <!-- Spring Web MVC框架将加载"classpath:spring-servlet-config.xml"来进行初始化上下文
                        而不是"/WEB-INF/[servlet名字]-servlet.xml" -->
                <!-- 去找src目录下的springmvc.xml文件 如果不指定目录和文件的话,
                    默认会去WEB-INF目录下找"servlet名+'-servlet'.xml文件"。
                    如:springmvc-servlet.xml-->
                 <param-value>classpath:springmvc.xml</param-value><!-- 配置自己的初始化参数,覆盖默认配置 -->
             </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
        
        <!-- 解决jsp页面数据传输到controller中中文乱码问题 -->
        <filter>
            <filter-name>characterEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>utf-8</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>characterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
    </web-app>
  • 相关阅读:
    动态规划——Best Time to Buy and Sell Stock IV
    动态规划——Split Array Largest Sum
    动态规划——Burst Ballons
    动态规划——Best Time to Buy and Sell Stock III
    动态规划——Edit Distance
    动态规划——Longest Valid Parentheses
    动态规划——Valid Permutations for DI Sequence
    构建之法阅读笔记05
    构建之法阅读笔记04
    构建之法阅读笔记03
  • 原文地址:https://www.cnblogs.com/xsl1995/p/7656746.html
Copyright © 2011-2022 走看看