Anytime an HTTP response is transmitted, a status code is included in the response. HTTP status codes are used to determine if the request was successful or if some type of error occurred and every code has a specific meaning.
The Spring framework uses an HttpStatus
enumeration (enum) to represent different HTTP status codes. If you are not familiar with enums in Java, you can learn about them in the Oracle documentation. See the below table for HTTP status code ranges and what each range represents. Also, if you’d like to see more information about specific status codes, you can learn about them here.
The actual constants in the HttpStatus
enum loosely match the status code name, e.g. a 201 Created code corresponds to HttpStatus.CREATED
and a 400 Bad Request code corresponds to HttpStatus.BAD_REQUEST
. The full list is on GitHub.
Instructions
Review the HTTP status code table.