web.xml配置

关于spring-springMVC-mybatis框架,web.xml的配置

<!--加载优先级context-param大于listener大于filter大于servlet-->
  
  <!-- ********************* 根目录设置 start ********************* -->
  <context-param>    
        <param-name>webAppRootKey</param-name>    
        <param-value>webName.root</param-value>    
  </context-param> 
  <!-- ********************* 根目录设置 end ********************* -->
  
  <!-- ********************* spring配置  start ********************* -->
  <!--spring配置有俩种方式-->
  <!--第一种 配置监听spring-->
  <!--该配置方式默认去找classpath下的application-Context.xml,若加上第二种方式后,则根据配置路径加载spring配置文件-->
  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!--第二种-->
  <!--路径跟具实际情况配置  classpath相当于web-info/classes/-->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/applicationcontext.xml</param-value>
  </context-param>
  <!-- ********************* spring配置  end *********************-->
  
  
  <!-- ********************* Log4j配置 start ********************* -->
    <!-- spring加载log4j的监听 -->
   <listener>
       <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
   </listener>
   <context-param>
       <param-name>log4jConfigLocation</param-name>
       <param-value>classpath:log4j.properties</param-value>
   </context-param>
   <!-- 3000表示 开一条watchdog线程每60秒扫描一下配置文件的变化;这样便于日志存放位置的改变 -->  
   <context-param>    
        <param-name>log4jRefreshInterval</param-name>    
        <param-value>3000</param-value>    
   </context-param> 
  <!-- ********************* Log4j配置 end  ********************* -->
  
  
  <!-- ********************* 配置spring字符编码为utf-8 start *********************-->
   <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字符编码为utf-8 end *********************-->
  
  
  <!--********************* springmvc配置 start *********************-->
  <servlet>
    <servlet-name>springMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <!--路径跟具实际情况配置  classpath相当于web-info/classes/-->
        <param-value>classpath:config/spring-servlet.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>
  <!-- ********************* springmvc配置 end ********************* -->  
  
  
  <!-- ********************* 欢迎页面 start ********************* -->
  <welcome-file-list>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <!-- ********************* 欢迎页面 end ********************* -->
  
  
  <!-- ********************* 错误页面配置 start *********************-->
  <!-- 常用的404和500页面 -->
  <error-page>
    <error-code>404</error-code>
    <location>/building.html</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/error.html</location>
  </error-page>
  <!-- ********************* 错误页面配置 end *********************-->

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值