异常:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined 
    (sessionFactory没有定义)

 

在web.xml中配置OpenSessionInViewFilter时应该指定SessionFactory的名字,配置如下:

 

<filter>  

      <filter-name>HibernateOpenSession</filter-name>   

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

     <init-param>  

       <param-name>sessionFactoryBeanName</param-name>  

      <param-value>mySessionFactory</param-value>

    </init-param>

</filter>  

Lazy问题可以通过加opensessioninviewfilter解决
在web.xml中加上
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

 

[转载自:http://blog.csdn.net/zxl0016/article/details/7875485]

 

相关文章:

  • 2021-05-15
  • 2021-11-08
  • 2021-12-26
  • 2021-07-30
  • 2021-10-01
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2021-06-05
  • 2021-07-12
  • 2022-12-23
  • 2021-05-22
  • 2021-08-19
  • 2022-01-03
  • 2022-12-23
相关资源
相似解决方案