[英]Spring 4 Session Management
I have concern regarding session creation in Spring 4 .我担心Spring 4 中的会话创建。
When ever any jsp page is rendered from server, spring creates session.每当从服务器呈现任何 jsp 页面时,spring 都会创建会话。 For example url is
GET /login
, then Login.jsp
served and session is automatically created and sent with response.例如 url 是
GET /login
,然后提供Login.jsp
和 session 自动创建并发送响应。
It is affecting my session handling, because I have filter which executes before DispatcherServlet
and checks for the session.它正在影响我的会话处理,因为我有过滤器在
DispatcherServlet
之前执行并检查会话。
If session is not active it redirects to login
, but after login.jsp
page is rendered then it creates session.如果 session 未处于活动状态,它会重定向到
login
,但在呈现login.jsp
页面后,它会创建 session。
So once page is passed to user his session gets activated and he can access the protected resource.因此,一旦页面传递给用户,他的会话就会被激活,他就可以访问受保护的资源。
I can solve this problem by adding some tokens but is there any way by which we can prevent session creation?我可以通过添加一些令牌来解决这个问题,但是有什么方法可以阻止会话创建?
I'm using spring 4. I've tried SessionCreationPolicy.STATELESS
and others but didn't work.我正在使用 spring 4。我尝试过
SessionCreationPolicy.STATELESS
和其他人,但没有奏效。
How to prevent session creation?如何防止会话创建?
Thanks,谢谢,
Sandeep桑迪普
This problem is not specific to Spring.这个问题不是 Spring 特有的。 JSP creates session by default.
JSP 默认创建会话。 So make sure that your JSPs don't implicitly do that by setting
<%@page session="false"%>
因此,请确保您的 JSP 不会通过设置
<%@page session="false"%>
隐式执行此操作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.