spring boot不通过参数获取request/response的方法

方式一:

ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();

HttpServletRequest request = servletRequestAttributes.getRequest();

HttpServletResponse response = servletRequestAttributes.getResponse();

方式二:

@Autowired

private HttpServletRequest request;

posted @ 2020-01-14 16:37  铭ㅤ  阅读(332)  评论(0)    收藏  举报