配置系列:ssm中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="MyWebApp" version="2.5">

<display-name>demo-sso</display-name>


<!-- 在classpath中加载spring自身的配置文件-->

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:spring/applicationContext*.xml</param-value>

</context-param>

<!--Spring的ApplicationContext 载入:Spring的监听器 -->

<listener>

    <listener-class>

                org.springframework.web.context.ContextLoaderListener

            </listener-class>

</listener>


<!-- 编码过滤器,以UTF8编码,解决乱码问题 -->

<filter>

<filter-name>encodingFilter</filter-name>

 <filter-class>

                    org.springframework.web.filter.CharacterEncodingFilter

                </filter-class>

<init-param>

<param-name>encoding</param-name>

<param-value>UTF8</param-value>

</init-param>

</filter>

<filter-mapping>

<filter-name>encodingFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>


<!-- 加载SpringMVC的配置文件-->

<servlet>

<servlet-name>demo-sso</servlet-name>

            <!--定义Spring的前端控制器DispatcherServlet-->

<servlet-class>

                    org.springframework.web.servlet.DispatcherServlet
                </servlet-class>

                <!--读取classpath下定义的springmvc的配置文件-->

<init-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:spring/simple-sso-servlet.xml</param-value>

</init-param>

                <!--设置加载顺序为1,优先加载-->

<load-on-startup>1</load-on-startup>


</servlet>

<!--使用的斜杠,拦截所有的以/simple/*url地址结尾的请求。-->

<servlet-mapping>

<servlet-name>simple-sso</servlet-name>

<url-pattern>/simple/*</url-pattern>

</servlet-mapping>

<!--默认首页-->

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

</web-app>


你可能感兴趣的:(spring,web.xml,配置)