Recently integrated SPRINGMVC found a bizarre error,No Hibernate Session bound to Thread, and configuration does not allow creation, is this ya, before the unit test test sessionfactory, test transaction passed, just I happy Run to do action, this ah to a bolt from the blue ah ... Without a little precaution, and without a trace of concern, he appeared, in my Code ... Because in the previous integration S2sh never appeared, all kinds of Goole, Baidu ..... But there are many great gods who have this wrong, but the solutions are different ... Not trusted, decisive access to spring official website to check the document, there has been a brother has not seen the east, it needs to define a filter in Web. XML
Say less nonsense, directly on:
- < Filter >
- <Filter-name>Opensessioninviewfilter</Filter-name>
- < Filter-class >
- org.springframework.orm.hibernate3.support.opensessioninviewfilter
- </ filter-class > &NBSP;&NBSP;
- </ filter > &NBSP;&NBSP;
- &NBSP;&NBSP;
- < filter-mapping >
- <Filter-name>Opensessioninviewfilter</Filter-name>
- <Url-pattern>/*</Url-pattern>
- </ filter-mapping >
Problem solving;
Springmvc No Hibernate Session bound to Thread