码迷,mamicode.com
首页 > Web开发 > 详细

配置系列:ssm中web.xml的简单配置

时间:2015-09-17 19:52:59      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:配置   spring   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>


配置系列:ssm中web.xml的简单配置

标签:配置   spring   web.xml   

原文地址:http://simplelife.blog.51cto.com/9954761/1695772

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!