spring web.xml

此文仅作为学习记录,以备以后总结查看。

web.xml配置:

1.servlet配置

org.springframework.web.servlet.DispatcherServlet

init-param配置servlet初始化文件

servlet-mapping配置

2.应用程序路径配置

webAppRootKey

3.spring上下文配置

contextConfigLocation

4.spring字符串过滤器配置

5.spring监听器配置 

6.log4j配置

log4jConfigLocation

7.log4j监听器配置

具体如下:

<welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <!-- 应用程序路径配置 -->
    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>hhweb.root</param-value>
    </context-param>
    <!-- log4j 配置 -->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:log4j.properties</param-value>
    </context-param>
    <!-- spring 上下文配置 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <!-- spring 字符集过滤器配置 -->
    <filter>
        <filter-name>encodingFilter</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>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- spring 监听器配置 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <!-- log4j 监听器配置 -->
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <!-- Servlet 配置 -->
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

 

posted on 2015-03-12 14:53  yingyi  阅读(247)  评论(0)    收藏  举报