Top Description Methods
org.springframework.http

public sealed Interface HttpStatusCode

extends Serializable
Known Direct Implementers
org.springframework.http.HttpStatus, org.springframework.http.DefaultHttpStatusCode
Imports
java.io.Serializable, org.springframework.util.Assert

Represents an HTTP response status code. Implemented by HttpStatus, but defined as an interface to allow for values not in that enumeration.
Author
Arjen Poutsma
Since
6.0
See Also
HTTP Status Code Registry, List of HTTP status codes - Wikipedia

Method Summary

Modifier and TypeMethod and Description
public boolean
is1xxInformational()

Whether this status code is in the Informational class (1xx).

public boolean
is2xxSuccessful()

Whether this status code is in the Successful class (2xx).

public boolean
is3xxRedirection()

Whether this status code is in the Redirection class (3xx).

public boolean
is4xxClientError()

Whether this status code is in the Client Error class (4xx).

public boolean
is5xxServerError()

Whether this status code is in the Server Error class (5xx).

public boolean
isError()

Whether this status code is in the Client or Server Error class

public default boolean

Returns:

true if the two HttpStatusCode objects share the same integer value(), false otherwise
isSameCodeAs
(HttpStatusCode
the other HttpStatusCode to compare
other
)

Whether this HttpStatusCode shares the same integer value as the other status code.

public int
value()

Return the integer value of this status code.

public static HttpStatusCode

Returns:

the corresponding HttpStatusCode
valueOf
(int
the status code as integer
code
)

Return an HttpStatusCode object for the given integer value.

Method Detail

is1xxInformationalback to summary
public boolean is1xxInformational()

Whether this status code is in the Informational class (1xx).

See Also
RFC 2616
is2xxSuccessfulback to summary
public boolean is2xxSuccessful()

Whether this status code is in the Successful class (2xx).

See Also
RFC 2616
is3xxRedirectionback to summary
public boolean is3xxRedirection()

Whether this status code is in the Redirection class (3xx).

See Also
RFC 2616
is4xxClientErrorback to summary
public boolean is4xxClientError()

Whether this status code is in the Client Error class (4xx).

See Also
RFC 2616
is5xxServerErrorback to summary
public boolean is5xxServerError()

Whether this status code is in the Server Error class (5xx).

See Also
RFC 2616
isErrorback to summary
public boolean isError()

Whether this status code is in the Client or Server Error class

See Also
RFC 2616, RFC 2616 (4xx or 5xx)., is4xxClientError(), is5xxServerError()
isSameCodeAsback to summary
public default boolean isSameCodeAs(HttpStatusCode other)

Whether this HttpStatusCode shares the same integer value as the other status code.

Useful for comparisons that take deprecated aliases into account or compare arbitrary implementations of HttpStatusCode (e.g. in place of HttpStatus enum equality).

Parameters
other:HttpStatusCode

the other HttpStatusCode to compare

Returns:boolean

true if the two HttpStatusCode objects share the same integer value(), false otherwise

Since
6.0.5
valueback to summary
public int value()

Return the integer value of this status code.

valueOfback to summary
public static HttpStatusCode valueOf(int code)

Return an HttpStatusCode object for the given integer value.

Parameters
code:int

the status code as integer

Returns:HttpStatusCode

the corresponding HttpStatusCode

Exceptions
IllegalArgumentException:
if code is not a three-digit positive number