Spring Framework

org.springframework.web.bind.annotation
Annotation Type ResponseStatus


@Target(value={TYPE,METHOD})
@Retention(value=RUNTIME)
@Documented
public @interface ResponseStatus

Marks a method or exception class with the status code and reason that should be returned. The status code is applied to the HTTP response when the handler method is invoked, or whenever said exception is thrown.

Since:
3.0
Author:
Arjen Poutsma
See Also:
ResponseStatusExceptionResolver

Required Element Summary
 HttpStatus value
          The status code to use for the response.
 
Optional Element Summary
 java.lang.String reason
          The reason to be used for the response.
 

Element Detail

value

public abstract HttpStatus value
The status code to use for the response.

See Also:
HttpServletResponse.setStatus(int)

reason

public abstract java.lang.String reason
The reason to be used for the response.

If this element is not set, it will default to the standard status message for the status code. Note that due to the use of HttpServletResponse.sendError(int, String), the response will be considered complete and should not be written to any further.

See Also:
HttpServletResponse.sendError(int, String)
Default:
""

Spring Framework