Class RequestDispatcher
The request attributes the server sets when it hands a request to the error page, under the names a servlet container uses, so an error controller ported from Spring Boot reads them unchanged:
@RequestMapping("/error")
public HttpServer.Response error(HttpServer.Request request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
Object path = request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI);
...
}
So are the errors the generated router answers itself -- a malformed
target, a body or parameter it cannot bind (400), a content type the route
does not consume (415) -- and an exception escaping a handler (500, or the
status of a ResponseStatusException), each with its own status.
A request no route, file or NoHandlerFoundException handler answers is
dispatched to the application's route for the error path -- /error, or
cn1.server.error.path, empty to turn the dispatch off -- with
these set, as Spring Boot forwards it to its ErrorController. Its answer is
sent with status 404 unless it chose another one itself. With no route at
that path the server's own plain-text 404 stands.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe exception that escaped the handler, aThrowable; absent when the error is not an exception (a path nothing serves, a body the router could not decode).static final StringA short description of the failure, aString.static final StringThe method of the request as it arrived, aString.static final StringThe path of the request as it arrived, without its query, aString.static final StringThe status the request would have been answered with, anInteger. -
Method Summary
-
Field Details
-
ERROR_STATUS_CODE
The status the request would have been answered with, anInteger.- See Also:
-
ERROR_REQUEST_URI
The path of the request as it arrived, without its query, aString.- See Also:
-
ERROR_MESSAGE
-
ERROR_METHOD
The method of the request as it arrived, aString. Not a servlet name: a forward keeps the method, and an error page that answers differently for a HEAD can read it here.- See Also:
-
ERROR_EXCEPTION
The exception that escaped the handler, aThrowable; absent when the error is not an exception (a path nothing serves, a body the router could not decode).- See Also:
-