Home > Back-end >  Questions about the referenced in SpringBoot HttpServletResponse, master answer
Questions about the referenced in SpringBoot HttpServletResponse, master answer

Time:02-06

SpringBoot, please see on the Internet there are three ways you can reference to the HttpServletResponse, respectively is
1, bound variables, namely direct write the objects in the parameter, springBoot will automatically binding,
2, by injecting the @autowired private HttpServletResponse response;
3, use code HttpServletResponse response=(.) (ServletRequestAttributes RequestContextHolder getRequestAttributes ()). The method getResponse (); Mode 1 and mode 2, 3, please what is the difference?
About this question, I have already sent a post https://bbs.csdn.net/topics/399056186, I met the problem now is that when I use the first method refer to the response object, I use it getoutputstream method, newspaper getWriter () has already had called for this response, but the method using 2, 3, do not quote this error, and these three methods in local is not an error, but the deployment of an error on the server,
  • Related