比如 controller 是这样的
@RestController
public class TestController{
@GetMapping(value="/test")
public CompletableFuture<Object> testController(){
.....
return CompletableFuture.completedFuture(service())
}
1.这种情况,当使用拦截器 preHandle 那里会执行 2 次输出结果
public Callable<Object> getTokenService(HttpSession httpSession) {
Map<String, Object> map = new HashMap<>(8);
String token = UUID.randomUUID().toString();
httpSession.setAttribute("token", token);
map.put("data", httpSession.getAttribute("token"));
return () -> map;
}
public Callable<Object> getTokenController(HttpSession httpSession){
return () -> service.getTokenService();
}
2.这种情况,用 redis 管理的 session,会发现就是只会在每次启动 server 后,第一次执行此方法时,token 会插入,当我再次请求这个方法时,session 里 token 的值始终是第一次的值
有大佬知道为什么吗?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.