What is the preferred way to specify an HTTP "Location" Response Header in Spring MVC 3?

Viewed 47979

What is the preferred way to specify an HTTP "Location" Response Header in Spring MVC 3?

As far as I can tell, Spring will only provide a "Location" in response to a redirect ("redirect:xyz" or RedirectView), however there are scenarios where a Location should be sent along with the entity body (ex, as a result of a "201 Created").

I'm afraid my only option is manually specifying it:

httpServletResponse.setHeader("Location", "/x/y/z");

Is this correct? Is there a better way to tackle this problem?

5 Answers
Related