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:
-
ErrorAttributesErrorProperties
-
Constructor Summary
ConstructorsConstructorDescriptionBasicErrorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties) Create a newBasicErrorControllerinstance.BasicErrorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties, List<ErrorViewResolver> errorViewResolvers) Create a newBasicErrorControllerinstance. -
Method Summary
Modifier and TypeMethodDescriptionerror(jakarta.servlet.http.HttpServletRequest request) org.springframework.web.servlet.ModelAndViewerrorHtml(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) protected org.springframework.boot.web.error.ErrorAttributeOptionsgetErrorAttributeOptions(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType mediaType) protected ErrorPropertiesProvide access to the error properties.protected booleanisIncludeBindingErrors(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the errors attribute should be included.protected booleanisIncludeMessage(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the message attribute should be included.protected booleanisIncludePath(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the path attribute should be included.protected booleanisIncludeStackTrace(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, getPathParameter, getStatus, getTraceParameter, resolveErrorView
-
Constructor Details
-
BasicErrorController
public BasicErrorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties) Create a newBasicErrorControllerinstance.- 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 newBasicErrorControllerinstance.- 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
-
isIncludePath
protected boolean isIncludePath(jakarta.servlet.http.HttpServletRequest request, org.springframework.http.MediaType produces) Determine if the path attribute should be included.- Parameters:
request- the source requestproduces- the media type produced (orMediaType.ALL)- Returns:
- if the path attribute should be included
- Since:
- 3.3.0
-
getErrorProperties
Provide access to the error properties.- Returns:
- the error properties
-