Why can't I get the currently requested HttpServletRequest object in the static method of the normal class?

I want to get a common getUser static method so that I don"t have to manually convert token to user in every controller

public class UserUtil {
    @Autowired
    private static HttpServletRequest request;

    @Autowired
    private static HttpServletResponse response;

    public static User getUser() {
        return null;
    }

    public static String getUserName() {
        System.out.println(request);
        System.out.println(response);
        String cookieToken =CookieUtils.getCookie(request,"token");
        System.out.println("cookieToken:" + cookieToken);

        String headerToken = request.getHeader("token");
        System.out.println("headerToken:" + headerToken);
        return headerToken;
    }
}

but this doesn"t get the request object, so what should I do?



spring mvcRequestContextHolderThreadLocal,DispatcherServlet

//
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38db1-406d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38db1-406d4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?