Original,That's how we configured the Interceptor.
<bean id= "Opensessioninviewinterceptor" class= " Org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor "> <property name=" Sessionfactory "ref=" sessionfactory "/> </bean> <beanclass=" Org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping "> <property name=" Interceptors "> <list> <ref bean=" Opensessioninviewinterceptor "/> <bean class=" Com.jumbo.interceptor.MetaInfoInterceptor "/> </list> </property> </bean>
The original configuration method combined with the new namespace mvc:interceptors configuration :
<mvc:annotation-driven/> <!--*************opensessioninviewinterceptor *************--> <bean id= "Opensessioninviewinterceptor" class= " Org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor "> <property name=" Sessionfactory "ref=" sessionfactory "/> </bean> <!-- **************interceptors ********* - <beanclass= " Org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping "> <property name=" Interceptors "> <list> <ref bean=" Opensessioninviewinterceptor "/> </list> </property> </bean> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path= "/**/*.htm"/> <bean id= "Metainfointerceptor" class= " Com.jumbo.web.interceptor.MetaInfoInterceptor "/> </mvc:interceptor> </mvc:interceptors >
Is that right???
Because <mvc:annotation-driven/> will voluntarily register defaultannotationhandlermapping and annotationmethodhandleradapter two instances,
<span style= "color: #FF6666;" ><beanclass= "Org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" ></ Span>
There's another one here that leads to no
opensessioninviewinterceptor, no session . Exception
So: Discard the original interceptor configuration to embrace the new method:
<mvc:annotation-driven/> <mvc:interceptors> <!--************* Opensessioninviewinterceptor *************-- <bean id= "Opensessioninviewinterceptor" class= " Org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor "> <property name=" Sessionfactory "ref=" sessionfactory "/> </bean> <mvc:interceptor> <mvc:mapping Path = "/**/*.htm"/> <bean id= "Metainfointerceptor" class= "Com.jumbo.web.interceptor.MetaInfoInterceptor"/ > </mvc:interceptor> </mvc:interceptors>
Spring Original Interceptor Configuration vs. New namespace Mvc:interceptors configuration Interceptor comparison and considerations