令牌拦截器和令牌会话拦截器之间的区别? [英] Difference between Token Interceptor and Token Session Interceptor?

查看:106
本文介绍了令牌拦截器和令牌会话拦截器之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道两个拦截器都用于防止重复提交表单吗?但是,两者之间到底有什么区别? 哪个比其他人更具优势?

I Know that both the interceptors are used to prevent duplicate form submissions? But What really are the difference between both of them? Which one has extra edge over other?

推荐答案

tokenSession扩展了token拦截器,它们都用于确保每个令牌仅处理一个请求.区别在于对无效令牌的处理. 当发现无效令牌时,token拦截器仅返回invalid.token结果.无效令牌上的tokenSession拦截器将尝试显示与有效令牌情况下相同的响应.

The tokenSession extends token interceptor, they are both used to ensure that only one request per token is processed. The difference is in the handling of the invalid tokens. When invalid token is found the token interceptor just returns invalid.token result. The tokenSession interceptor on invalid token will try to display the same response that would have been displayed in case of valid token.

一些用于说明tokenSession拦截器工作流程的伪代码:

Some pseudo code for illustrating workflow of the tokenSession interceptor:

intercept() {
  if(validToken){
    storeInvocation();
    return invocation.invoke();
  }else {
    ActionInvocation storedInvocation = loadStoredInvocation();
    // ...
    return storedInvocation.getResultCode();
  }
}

这篇关于令牌拦截器和令牌会话拦截器之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆