在web.xml中添加过滤器,内容如下:
  <!-- openSessionInView,在struts2的FilterDispatcher之前-->        
  <filter>        
    <filter-name>openSessionInView</filter-name>        
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>        
  </filter>        
        <filter-mapping>        
                <filter-name>openSessionInView</filter-name>        
                <url-pattern>*.action</url-pattern>        
        </filter-mapping>        
                
        <!-- spring listener -->        
        <listener>        
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>        
        </listener>        
    
        <!--struts2-->        
        <filter>        
                <filter-name>struts</filter-name>        
                <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>        
        </filter>        
        <filter-mapping>        
                <filter-name>struts</filter-name>        
                <url-pattern>*.action</url-pattern>        
        </filter-mapping>        
    
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
 
 
还可以使用hibernateTemplate替代sessionFactory。
  <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
                <property name="sessionFactory" ref="sessionFactory"/>
        </bean>
 
然后在dao中将其替换为sessionFactory即可。