opensessioninview的学习

opensessioninview降session绑定到当前线程,这样解决了hibernate的延迟加载问题
但是在web.xml中配置filter还是出现了一些小插曲
之前认为加上
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
就可以了,结果报错
No WebApplicationContext found: no ContextLoaderListener registered?
最后的解决办法
web.xml中加入
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
解决问题

你可能感兴趣的:(Web,Hibernate,xml,orm)