SpringMVC中web.xml的常用配置文件


    <filter>
        <filter-name>multipartFilterfilter-name>
        <filter-class>org.springframework.web.multipart.support.MultipartFilterfilter-class>
    filter>
    <filter-mapping>
        <filter-name>multipartFilterfilter-name>
        <url-pattern>/url-pattern>
    filter-mapping>
-- 
    请求method支持 putdelete 必须添加该过滤器
    作用:可以过滤所有请求,并可以分为四种
    使用该过滤器需要在前端页面加隐藏表单域
    "hidden" name="_method" value="请求方式(put/delete)">
    post会寻找_method中的请求式是不是put 或者 delete,如果不是 则默认post请求
-->
    <filter>
        <filter-name>hiddenHttpFilterfilter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilterfilter-class>
    filter>
    <filter-mapping>
        <filter-name>hiddenHttpFilterfilter-name>
        mvc
    filter-mapping>

    <filter>
        <filter-name>encodingFilterfilter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
        <init-param>
            <param-name>encodingparam-name>
            <param-value>utf-8param-value>
        init-param>
        <init-param>
            <param-name>forceEncodingparam-name>
            <param-value>trueparam-value>
        init-param>
    filter>
    <filter-mapping>
        <filter-name>encodingFilterfilter-name>
        <url-pattern>/*url-pattern>
    filter-mapping>

    <servlet>
        <servlet-name>mvcservlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
        <load-on-startup>1load-on-startup>
    servlet>
    <servlet-mapping>
        <servlet-name>mvcservlet-name>
        <url-pattern>/url-pattern>
    servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.jspwelcome-file>
    welcome-file-list>

你可能感兴趣的:(springmvc)