ThreadLocal 类定义
public class UserContext {
public static final ThreadLocal<String> USER_NAME = new ThreadLocal<>();
}
拦截器编写
@Component
public class UserSecurityInterceptor implements HandlerInterceptor {
public static final Logger logger = LoggerFactory.getLogger(UserSecurityInterceptor.class);
@Autowired
private UserInfoCacheManager userInfoCacheManager;
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
response.setHeader("Access-Control-Allow-Origin", request.getHeader("origin"));
response.setHeader("Access-Control-Allow-Headers"</