错误的初始化方式导致用户被踢下线

出现原因

类中代码会出现此种情况,多次请求会出现并发问题,导致request获取不到,用户被踢下线

private HttpServletRequest request;
private HttpServletResponse response;

@ModelAttribute
public void init(HttpServletRequest request, HttpServletResponse response) {
    this.request = request;
    this.response = response;
}

修复问题

改用直接注入的方式获取request、response

@Autowired
private HttpServletRequest request;
@Autowired
private HttpServletResponse response;
# 随记 
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×