• 杂记_ssm之web.xml配置


    1.项目加载spring

    <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:/config/spring/spring*.xml</param-value>
    </context-param>

    2.加载log4j

        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>WEB-INF/log4j.properties</param-value>
        </context-param>

        <context-param>
            <param-name>log4jRefreshInterval</param-name>
            <param-value>60000</param-value>
        </context-param>

        <listener>
            <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
        </listener> 

     
     3.字符过滤器

    <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>

    4.配置springmvc

    <servlet>
      <servlet-name>springServlet</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/config/spring-mvc.xml</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>springServlet</servlet-name>
      <url-pattern>/</url-pattern>
    </servlet-mapping>

    5.配置session失效

    <session-config>
      <session-timeout>600</session-timeout>
    </session-config>

    6.异常处理

    <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/WEB-INF/views/error/500.jsp</location>
    </error-page>
    <error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/views/error/500.jsp</location>
    </error-page>
    <error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/views/web/error/error404.jsp</location>
    </error-page>

  • 相关阅读:
    redis主从之过期key判断
    PHP之回调、匿名函数
    调试printf,fprintf (转)
    第一天,来报道
    hdu 4464 browsing history
    腾讯编程马拉松2012第一题
    今天面试悲剧了,看来面试前看考题是很关键的.
    JQuery访问WebService(可访问Java[Xfire])
    自己留备份,不解释.
    MYSQL UNION AND UNION ALL 的区别!
  • 原文地址:https://www.cnblogs.com/songfahzun/p/6626480.html
Copyright © 2020-2023  润新知