【发布时间】:2019-05-08 03:28:24
【问题描述】:
问题描述(似乎是时间问题):
使用SpringSessionRepositoryFilter后,会话对象为空 每个请求开始时OtherFilter的处理周期
我尝试过的:
- 在OtherFilter之后的Controller和JSP中,session对象不为空,工作正常
- 不使用springSessionRepositoryFilter,session对象是notempty,在OtherFilter中可以正常工作
配置如下:
<bean class="org.springframework.web.filter.CompositeFilter" name="springChainFilter">
<property name="filters">
<list>
<bean id="springSessionRepositoryFilter" class="org.springframework.session.web.http.SessionRepositoryFilter">
</bean>
<!--Other Later Filter -->
<bean id="otherFilter" class="xxx.xxx.OtherFilter">
</bean>
</list>
</property>
</bean>
<bean class="org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration"/>
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<constructor-arg ref="dataSource"/>
</bean>
<bean id="cookieSerializer" class="org.springframework.session.web.http.DefaultCookieSerializer">
<property name="cookieName" value="JSESSIONID" />
</bean>
OtherFilter 定义如下:
public class OtherFilter extends OncePerRequestFilter {
@Autowired
private SessionObj sessionObj;
......
}
会话对象定义如下:
@Component
@SessionScope
public class SessionObj implements Serializable {
private static final long serialVersionUID = 1L;
private String xxId;
......
}
环境版本信息:
- spring-session-jdbc-2.1.5.RELEASE
- wildfly-11.0.0.Final
- Oracle Database 18c Express Edition Release 18.0.0.0.0
【问题讨论】:
标签: spring jdbc spring-session