简体   繁体   English

在春季注销特定的请求映射

[英]Logout on particular request mappings in spring

I need on a particular RequestMapping make user logout. 我需要在特定的RequestMapping上使用户注销。 It can be several requestMappings. 可以是几个requestMappings。 It would be fine if special annotation exist to do this. 如果存在特殊注释可以做到这一点。

Thanks in advance 提前致谢

If you are using spring authentication service (Spring Security), you can do it through configuration whereby you set a logout url and spring takes care of it. 如果您使用的是Spring身份验证服务(Spring Security),则可以通过配置来完成此操作,从而设置注销url,Spring会进行处理。

Otherwise, you can yourself map an url as logout and upon invocation, you should invalidate the user session. 否则,您可以自己将URL映射为注销,并且在调用时应使用户会话无效。

If you want to check if the user is logged in or not, you should check existence of already created session first. 如果要检查用户是否已登录,则应首先检查是否已创建会话。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM