Annotation Interface ResponseStatus
reason()that should be returned.
The status code is applied to the HTTP response when the handler
method is invoked and overrides status information set by other means,
Warning: when using this annotation on an exception
class, or when setting the
reason attribute of this annotation,
HttpServletResponse.sendError method will be used.
HttpServletResponse.sendError, the response is considered
complete and should not be written to any further. Furthermore, the Servlet
container will typically write an HTML error page therefore making the
use of a
reason unsuitable for REST APIs. For such cases it is
preferable to use a
a return type and avoid the use of
Note that a controller class may also be annotated with
@ResponseStatus which is then inherited by all
@ExceptionHandler methods in that class and its subclasses unless
overridden by a local
@ResponseStatus declaration on the method.
- Arjen Poutsma, Sam Brannen
- See Also:
Optional Element SummaryModifier and TypeOptional ElementDescriptionThe status code to use for the response.The reason to be used for the response.
value@AliasFor("code") HttpStatus value
code@AliasFor("value") HttpStatus codeThe status code to use for the response.
HttpStatus.INTERNAL_SERVER_ERROR, which should typically be changed to something more appropriate.
- See Also:
reasonString reasonThe reason to be used for the response.
Defaults to an empty string which will be ignored. Set the reason to a non-empty value to have it used for the response.