Class BasicErrorController
java.lang.Object
org.springframework.boot.webmvc.autoconfigure.error.AbstractErrorController
org.springframework.boot.webmvc.autoconfigure.error.BasicErrorController
- All Implemented Interfaces:
ErrorController
@Controller
@RequestMapping("${spring.web.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
registering error pages.- Since:
- 4.0.0
- Author:
- Dave Syer, Phillip Webb, Michael Stummvoll, Stephane Nicoll, Scott Frederick, Moritz Halbritter
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBasicErrorController(ErrorAttributes errorAttributes, ErrorProperties errorProperties) Create a newBasicErrorControllerinstance.BasicErrorController(ErrorAttributes errorAttributes, ErrorProperties errorProperties, List<ErrorViewResolver> errorViewResolvers) Create a newBasicErrorControllerinstance. -
Method Summary
Modifier and TypeMethodDescriptionerror(HttpServletRequest request) errorHtml(HttpServletRequest request, HttpServletResponse response) protected ErrorAttributeOptionsgetErrorAttributeOptions(HttpServletRequest request, MediaType mediaType) protected ErrorPropertiesProvide access to the error properties.protected booleanisIncludeBindingErrors(HttpServletRequest request, MediaType produces) Determine if the errors attribute should be included.protected booleanisIncludeMessage(HttpServletRequest request, MediaType produces) Determine if the message attribute should be included.protected booleanisIncludePath(HttpServletRequest request, MediaType produces) Determine if the path attribute should be included.protected booleanisIncludeStackTrace(HttpServletRequest request, MediaType produces) Determine if the stacktrace attribute should be included.mediaTypeNotAcceptable(HttpServletRequest request) Methods inherited from class AbstractErrorController
getBooleanParameter, getErrorAttributes, getErrorsParameter, getMessageParameter, getPathParameter, getStatus, getTraceParameter, resolveErrorView
-
Constructor Details
-
BasicErrorController
Create a newBasicErrorControllerinstance.- Parameters:
errorAttributes- the error attributeserrorProperties- configuration properties
-
BasicErrorController
public BasicErrorController(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 ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) -
error
-
mediaTypeNotAcceptable
@ExceptionHandler(HttpMediaTypeNotAcceptableException.class) public ResponseEntity<String> mediaTypeNotAcceptable(HttpServletRequest request) -
getErrorAttributeOptions
protected ErrorAttributeOptions getErrorAttributeOptions(HttpServletRequest request, MediaType mediaType) -
isIncludeStackTrace
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
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
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
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
-
getErrorProperties
Provide access to the error properties.- Returns:
- the error properties
-