zoukankan      html  css  js  c++  java
  • ssm框架下web项目,web.xml配置文件的作用

    1. web.xml中配置了CharacterEncodingFilter,配置这个是拦截所有的资源并设置好编号格式。

      encoding设置成utf-8就相当于request.setCharacterEncoding("UTF-8");  

      foreEncoding设置成true就相当于response.setCharacterEncoding("UTF-8");

    <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>  
      <init-param>  
        <param-name>forceEncoding</param-name> 
        <param-value>true</param-value>  
      </init-param> 
    </filter>  
    <filter-mapping>  
        <filter-name>CharacterEncodingFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>
    

    2. web.xml配置DispatcherServlet,配置这个是拦截所有请求,都交给springmvc转发

      拦截所有的请求,并加载所有的ssm配置文件(路径为classpath:---)

    <servlet>
    	<servlet-name>mvc-dispatcher</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath:spring-*.xml</param-value>
    	</init-param>
    </servlet>
    <servlet-mapping>
    	<servlet-name>mvc-dispatcher</servlet-name>
    	<url-pattern>/</url-pattern>
    </servlet-mapping>
    

      

  • 相关阅读:
    Tomcat启动过程[更详细]
    数据库连接池原理
    Druid
    Spring的注解积累
    React基础知识
    mac里git项目删除.DS_Store文件
    GET请求参数为中文时乱码分析
    npm中package.json详解
    前后端分离工具之ftl-server
    利用performance属性查看网页性能
  • 原文地址:https://www.cnblogs.com/winv758241/p/6889383.html
Copyright © 2011-2022 走看看