最近在使用SSM整合一个通用的后台管理系统,记录一下自己的整合过程,方便以后查阅,今天我们来说一下web.xml,该配置文件通常放置在WebRoot/WEB-INF文件夹下面,该配置文件会随着自己的整合不断修改。配置文件如下:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>cesoftBaseSystem</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> <!--结束定义默认启动页--> <!--开始配置异常处理 --> <error-page> <error-code>404</error-code> <location>/404.html</location> </error-page> <error-page> <error-code>505</error-code> <location>/505.html</location> </error-page> <error-page> <exception-type>javax.servle.ServletException</exception-type> <location>/error.html</location> </error-page> <error-page> <exception-type>java.lang.NullPointerException</exception-type> <location>/error.html</location> </error-page> <!--结束配置异常处理 --> <!-- 开始配置spring核心监听器,默认会以 /WEB-INF/spring.xml作为配置文件 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- contextConfigLocation参数用来指定Spring的配置文件--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring.xml</param-value> </context-param> <!-- 结束配置spring核心监听器--> <!--开始定义Spring MVC的前端控制器,默认路径是/WEB-INF/{servlet-name}-servlet.xml,可以修改名称及路径--> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/springmvc-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 --> <url-pattern>/</url-pattern> </servlet-mapping> <!--结束定义Spring MVC的前端控制器 --> <!-- 解决工程编码过滤器开始 --> <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> 文章来源: SSM整合之web.xml