【发布时间】:2016-11-07 17:31:03
【问题描述】:
我有一个奇怪的问题,无法解决。
问题:
我登录到我的 Spring Web 应用程序,它有很长的会话超时,每当我退出浏览器然后重新打开它时,访问我的 Web 应用程序,我每次都会看到登录页面。
只要浏览器没有关闭,它就可以正常工作。我以为chrome设置有问题,但事实并非如此。所有浏览器也会发生这种情况。
我的web.xml:
<session-config>
<session-timeout>10000</session-timeout>
<cookie-config>
<name>myapp</name>
<http-only>true</http-only>
</cookie-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
我的 Spring Security 配置:
<security:http auto-config="true" use-expressions="true">
<security:intercept-url pattern="/resources/**" access="permitAll" />
<security:intercept-url pattern="/login" access="permitAll" />
<security:intercept-url pattern="/login/forgot" access="permitAll" />
<security:intercept-url pattern="/login/resetpassword" access="permitAll" />
<security:intercept-url pattern="/home/admin/**" access="hasAnyRole('ROLE_admin', 'ROLE_manager')" />
<security:intercept-url pattern="/**" access="hasAnyRole('ROLE_admin', 'ROLE_manager','ROLE_user')" />
<security:form-login
login-page="/login"
login-processing-url="/login"
authentication-failure-handler-ref="authenticationFailureFilter"
authentication-success-handler-ref="authenticationSuccessHandler"
username-parameter="email"
password-parameter="password" />
<!-- enable csrf protection -->
<security:csrf/>
</security:http>
我的web.xml 或 Spring Security 有什么问题吗?
【问题讨论】:
-
检查javax.http.servlet.cookie类的最大年龄属性,默认值为-1,即如果浏览器关闭则删除cookie。
-
@notionquest 是的,问题解决了
-
添加了答案。如果有用请采纳。谢谢!
标签: java spring spring-mvc spring-security tomcat7