Class BasicErrorController
java.lang.Object
org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController
org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController
- All Implemented Interfaces:
org.springframework.boot.web.servlet.error.ErrorController
@Controller
@RequestMapping("${server.error.path:${error.path:/error}}")
public class BasicErrorController
extends AbstractErrorController
Basic global error
@Controller
, rendering ErrorAttributes
.
More specific errors can be handled either using Spring MVC abstractions (e.g.
@ExceptionHandler
) or by adding servlet
server error pages
.- Since:
- 1.0.0
- See Also:
-
ErrorAttributes
ErrorProperties
-
Constructor Summary
ConstructorDescriptionBasicErrorController
(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties) Create a newBasicErrorController
instance.BasicErrorController
(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties, List<ErrorViewResolver> errorViewResolvers) Create a newBasicErrorController
instance. -
Method Summary
Modifier and TypeMethodDescriptionerror
(jakarta.servlet.http.HttpServletRequest request) org.springframework.web.servlet.ModelAndView
errorHtml
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) protected org.springframework.boot.web.error.ErrorAttributeOptions
getErrorAttributeOptions
(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType mediaType) protected ErrorProperties
Provide access to the error properties.protected boolean
isIncludeBindingErrors
(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the errors attribute should be included.protected boolean
isIncludeMessage
(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the message attribute should be included.protected boolean
isIncludeStackTrace
(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the stacktrace attribute should be included.org.springframework.http.ResponseEntity<String>
mediaTypeNotAcceptable
(jakarta.servlet.http.HttpServletRequest request) Methods inherited from class org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController
getBooleanParameter, getErrorAttributes, getErrorsParameter, getMessageParameter, getStatus, getTraceParameter, resolveErrorView
-
Constructor Details
-
BasicErrorController
public BasicErrorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties) Create a newBasicErrorController
instance.- Parameters:
errorAttributes
- the error attributeserrorProperties
- configuration properties
-
BasicErrorController
public BasicErrorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties, List<ErrorViewResolver> errorViewResolvers) Create a newBasicErrorController
instance.- Parameters:
errorAttributes
- the error attributeserrorProperties
- configuration propertieserrorViewResolvers
- error view resolvers
-
-
Method Details
-
errorHtml
@RequestMapping(produces="text/html") public org.springframework.web.servlet.ModelAndView errorHtml(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) -
error
-
mediaTypeNotAcceptable
@ExceptionHandler(org.springframework.web.HttpMediaTypeNotAcceptableException.class) public org.springframework.http.ResponseEntity<String> mediaTypeNotAcceptable(jakarta.servlet.http.HttpServletRequest request) -
getErrorAttributeOptions
protected org.springframework.boot.web.error.ErrorAttributeOptions getErrorAttributeOptions(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType mediaType) -
isIncludeStackTrace
protected boolean isIncludeStackTrace(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the stacktrace attribute should be included.- Parameters:
request
- the source requestproduces
- the media type produced (orMediaType.ALL
)- Returns:
- if the stacktrace attribute should be included
-
isIncludeMessage
protected boolean isIncludeMessage(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the message attribute should be included.- Parameters:
request
- the source requestproduces
- the media type produced (orMediaType.ALL
)- Returns:
- if the message attribute should be included
-
isIncludeBindingErrors
protected boolean isIncludeBindingErrors(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the errors attribute should be included.- Parameters:
request
- the source requestproduces
- the media type produced (orMediaType.ALL
)- Returns:
- if the errors attribute should be included
-
getErrorProperties
Provide access to the error properties.- Returns:
- the error properties
-