zoukankan      html  css  js  c++  java
  • 在SpringMVC框架下建立Web项目时web.xml到底该写些什么呢?

    刚刚初学Spring MVC,却连一个简单的helloworld都搞的懵懵懂懂的,配置文件搞不清,各种文件之间的逻辑关系也不懂,连续看了好些日子的Spring MVC了,今天终于下定决心,每天记录一点,下面是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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/root-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <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> <!-- <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> --> <!-- HiddenHttpMethodFilter,因为html中的form表单只支持GET与POST请求,spring为了支持DELETE, PUT等操作,会在生成页面代码时,会把我们希望的操作添加到一个hidden的_method中,在外层通过post传过去,所以我们需要通过 HiddenHttpMethodFilter把真实的操作解析出来。 --> <!-- <filter> <filter-name>hiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>hiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/404</location> </error-page> <!-- <error-page> <error-code>500</error-code> <location>/500</location> </error-page> --> </web-app>
  • 相关阅读:
    ionic app打包和签名
    js时间戳与日期格式的相互转换
    js获取选中日期的当周的周一和周日
    Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap
    CSS媒体查询 @media
    [ng:areq] Argument 'XXXXCtrl' is not a function, got undefined
    plsql如何导出查询结果
    angularjs的$http请求方式
    JQuery请求数据的方式
    后台返回xml格式转json
  • 原文地址:https://www.cnblogs.com/suixue/p/5709844.html
Copyright © 2011-2022 走看看