`
Listen_ing
  • 浏览: 35344 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

web.xml配置文件全文

阅读更多
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
     </welcome-file-list>


     <!-- 配置上下文 -->
     <!-- 作用:定义Spring配置文件位置,可以定义多个文件,也可以使用通配符 -->
     <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>
               WEB-INF/classes/applicationContext.xml,WEB-INF/classes/spring/spring-*.xml
         </param-value>


          <!-- ,ssss.xml(为spring的配置文件) -->
     </context-param>


     <!-- Struts2过滤器 -->
     <filter>
          <filter-name>struts2</filter-name>
          <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
     </filter>


     <!-- 解决hibernate延迟加载出现的问题,要放在Struts2过滤器之前 -->
     <!--
          作用:Spring管理hibernate的Session,在事务管理的类执行完后,不立刻关闭Session,
          而将Session保存在一个线程变量中,在线程退出前关闭Session;这样在整个request过程中
          始终使用一个session,也就可以在request的任何时期lazy loading数据。 主要是为了实现hibernate的延迟加载功能
     -->


     <filter>
          <filter-name>lazyLoadingFilter</filter-name>
          <filter-class>
                org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>


          <!-- singleSession默认设置为true,如何为false就等于没有设置OpenSessionInView -->


          <init-param>
                <param-name>singleSession</param-name>
                <param-value>true</param-value>
          </init-param>
     </filter>




     <!-- 配置Spring监听器 -->
     <!-- 作用:启动web应用,就加载Spring,让Spring管理Bean -->
     <listener>
           <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>


     <!-- 解决hibernate延迟加载出现的问题,仍需要放在Struts2过滤器的filter-mapping之前 -->


     <filter-mapping>
          <filter-name>lazyLoadingFilter</filter-name>
          <url-pattern>*.action</url-pattern>
     </filter-mapping>


     <filter-mapping>
          <filter-name>struts2</filter-name>
          <url-pattern>/*</url-pattern>
     </filter-mapping>


</web-app>


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics