@RestControllerpublicclassController{
privatefinalHttpServletRequest httpServletRequest;@AutowiredpublicController(HttpServletRequest httpServletRequest){
this
可以将HttpServletRequest 以成员的方式注入到控制器中,和原来直接加在方法参数里是一个效果。@RestControllerpublic class Controller{ private final HttpServletRequest httpServletRequest; @Autowired public Controller(HttpServletRequest httpServletRequest) { this.httpServletRequest =