Spring MVC - the answer

How can I access the response object from the bean? To get the request object, I use the following.

    ServletRequestAttributes attr = (ServletRequestAttributes) 


Is there something similar to the above for the response object?


source to share

1 answer

If you are in the context of a web application (it looks like you), you can automatically connect to HttpServletRequest or HttpServletResponse.

A request / response from the current request area will be entered.

public class SomeComponentInAWebApplicationContext {

    private HttpServletRequest request;

    private HttpServletResponse response;





All Articles