Could not obtain transaction-synchronized Session for current thread

配置session有误:在项目中通常都是自动打开session和关闭session,须要在web.xml中加入以下代码:web

  

<filter>  <filter-name>SpringOpenSessionInViewFilter</filter-name>  <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class></filter><filter-mapping>  <filter-name>SpringOpenSessionInViewFilter</filter-name>  <url-pattern>/*</url-pattern></filter-mapping>这里的singleSession的默认值为true,也就是自动打开和关闭session
相关文章
相关标签/搜索