SSH integration in the versions are: Struts2, Hibernate4, Spring4
In the integration, the Opensessioninviewfilter filter is added to the Web.xml, as follows:
<!--configuration Struts2 filter-->
<filter>
<filter-name>struts2</filter-name>
< Filter-class>org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
< url-pattern>/*</url-pattern>
</filter-mapping>
<!--configuration Opensessioninviewfilter Filter-- >
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
< Filter-class>org.springframework.orm.hibernate4.support.opensessioninviewfilter</filter-class>
</filter>
<filter-mapping>
<filter-name>opensessioninviewfilter</filter-name >
<url-pattern>/*</url-pattern>
</filter-mapping>
However, the filter is not in effect and will still report no session exception.
Accidentally fiddling with the code, the Opensessioninviewfilter placed in front of the Struts2 filter, the problem is resolved.
Specifically as follows:
<!--configuration Opensessioninviewfilter filter-->
<filter>
<filter-name>opensessioninviewfilter </filter-name>
<filter-class> Org.springframework.orm.hibernate4.support.opensessioninviewfilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
< url-pattern>/*</url-pattern>
</filter-mapping>
<!--Configure STRUTS2 filter-->
< filter>
<filter-name>struts2</filter-name>
<filter-class> Org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter</filter-class>
</filter >
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/ *</url-pattern>
</filter-mapping>
It seems that the order of the filter is also very important ah ...