简体   繁体   English

令牌拦截器在Struts 2中如何工作

[英]How Token Interceptor work in Struts 2

Struts2 provide Token Interceptor for ensures that only one request per token is processed, But, I don't understand how it works, if a user send the one request twice what happens? Struts2提供Token Interceptor来确保每个令牌仅处理一个请求,但是,我不明白它是如何工作的,如果用户两次发送一个请求,会发生什么? Does the user get an invalid token or get response of the first request? 用户会收到无效的令牌还是得到第一个请求的响应? What is a logic behind this interceptor? 这个拦截器背后的逻辑是什么?

The token interceptor returns the result invalid.token when an invalid token is found. 当发现无效令牌时, token拦截器将返回结果invalid.token The logic is simple: it uses a session to save a valid token per request and when intercept it checks it by comparing one that sent and other that is from session. 逻辑很简单:它使用会话为每个请求保存有效令牌,并在拦截时通过比较发送的会话和会话中的另一个令牌进行检查。

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

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