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:
  • Constructor Details

    • BasicErrorController

      public BasicErrorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties)
      Create a new BasicErrorController instance.
      Parameters:
      errorAttributes - the error attributes
      errorProperties - configuration properties
    • BasicErrorController

      public BasicErrorController(org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributes, ErrorProperties errorProperties, List<ErrorViewResolver> errorViewResolvers)
      Create a new BasicErrorController instance.
      Parameters:
      errorAttributes - the error attributes
      errorProperties - configuration properties
      errorViewResolvers - 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

      @RequestMapping public org.springframework.http.ResponseEntity<Map<String,Object>> error(jakarta.servlet.http.HttpServletRequest request)
    • 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 request
      produces - the media type produced (or MediaType.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 request
      produces - the media type produced (or MediaType.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 request
      produces - the media type produced (or MediaType.ALL)
      Returns:
      if the errors attribute should be included
    • getErrorProperties

      protected ErrorProperties getErrorProperties()
      Provide access to the error properties.
      Returns:
      the error properties