【已解决】 在编写了checkUser过后,启动springboot就会报错
//checkUser()中调用getCookie()
String tokenKey = CookieUtil.getCookie(request,Constants.User.COOKIE_TOKEN_KEY);
//CookieUtil类中的 getCookie
public static String getCookie(HttpServletRequest request, String key) {
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {
if (key.equals(cookie.getName())) {
return cookie.getValue();
}
}
return null;
}
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
你可以注释掉判断是不是你新增加的代码有问题,这样子就可以定位了。如果你都确定了你新写的代码有问题,再细细检查。
无法获取request,你提供全的代码嘛,你请求了什么接口,这个调用过程的代码补充到问题里吧。