Class BasicErrorController
java.lang.Object
org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController
org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController
- All Implemented Interfaces:
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
- Author:
- Dave Syer, Phillip Webb, Michael Stummvoll, Stephane Nicoll, Scott Frederick
- See Also:
-
Constructor Summary
ConstructorDescriptionBasicErrorController
(ErrorAttributes errorAttributes, ErrorProperties errorProperties) Create a newBasicErrorController
instance.BasicErrorController
(ErrorAttributes errorAttributes, ErrorProperties errorProperties, List<ErrorViewResolver> errorViewResolvers) Create a newBasicErrorController
instance. -
Method Summary
Modifier and TypeMethodDescriptionerror
(HttpServletRequest request) errorHtml
(HttpServletRequest request, HttpServletResponse response) protected ErrorAttributeOptions
getErrorAttributeOptions
(HttpServletRequest request, MediaType mediaType) protected ErrorProperties
Provide access to the error properties.protected boolean
isIncludeBindingErrors
(HttpServletRequest request, MediaType produces) Determine if the errors attribute should be included.protected boolean
isIncludeMessage
(HttpServletRequest request, MediaType produces) Determine if the message attribute should be included.protected boolean
isIncludeStackTrace
(HttpServletRequest request, MediaType produces) Determine if the stacktrace attribute should be included.mediaTypeNotAcceptable
(HttpServletRequest request) Methods inherited from class org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController
getBooleanParameter, getErrorAttributes, getErrorsParameter, getMessageParameter, getStatus, getTraceParameter, resolveErrorView
-
Constructor Details
-
BasicErrorController
Create a newBasicErrorController
instance.- Parameters:
errorAttributes
- the error attributeserrorProperties
- configuration properties
-
BasicErrorController
public BasicErrorController(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 ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) -
error
-
mediaTypeNotAcceptable
@ExceptionHandler(org.springframework.web.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
-
getErrorProperties
Provide access to the error properties.- Returns:
- the error properties
-