Affects: 5.2.0.RELEASE

The following should work for request scoped beans:

    @Component
    @RequestScope
    public class RequestScopeBean {
        @Autowired HttpServletRequest request;
        @Autowired HttpServletResponse response; // <-- error
    }

Additional resources:

  • http://jawspeak.com/2010/05/06/injecting-httpservletresponse-into-spring-mvc-request-scoped-interceptors/
  • https://stackoverflow.com/questions/6984054/autowired-httpservletresponse

Comment From: bclozel

Sorry it took us so long to respond.

I've just tested this against supported version and it works. I think this was introduced in #16416. Note that you'll need to ensure that the scoped bean is injected in a way that Spring can use proxying. Maybe the injection point was invalid in your case?

I'm closing this issue as a result.