org.springframework.web.servlet.mvc.annotation

Class ResponseStatusExceptionResolver

    • Constructor Detail

      • ResponseStatusExceptionResolver

        public ResponseStatusExceptionResolver()
    • Method Detail

      • setMessageSource

        public void setMessageSource(MessageSource messageSource)
        Description copied from interface: MessageSourceAware
        Set the MessageSource that this object runs in.

        Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext.

        Specified by:
        setMessageSource in interface MessageSourceAware
        Parameters:
        messageSource - message sourceto be used by this object
      • doResolveException

        @Nullable
        protected ModelAndView doResolveException(HttpServletRequest request,
                                                            HttpServletResponse response,
                                                            @Nullable
                                                            java.lang.Object handler,
                                                            java.lang.Exception ex)
        Description copied from class: AbstractHandlerExceptionResolver
        Actually resolve the given exception that got thrown during handler execution, returning a ModelAndView that represents a specific error page if appropriate.

        May be overridden in subclasses, in order to apply specific exception checks. Note that this template method will be invoked after checking whether this resolved applies ("mappedHandlers" etc), so an implementation may simply proceed with its actual exception handling.

        Specified by:
        doResolveException in class AbstractHandlerExceptionResolver
        Parameters:
        request - current HTTP request
        response - current HTTP response
        handler - the executed handler, or null if none chosen at the time of the exception (for example, if multipart resolution failed)
        ex - the exception that got thrown during handler execution
        Returns:
        a corresponding ModelAndView to forward to, or null for default processing in the resolution chain
      • applyStatusAndReason

        protected ModelAndView applyStatusAndReason(int statusCode,
                                                    @Nullable
                                                    java.lang.String reason,
                                                    HttpServletResponse response)
                                             throws java.io.IOException
        Apply the resolved status code and reason to the response.

        The default implementation sends a response error using HttpServletResponse.sendError(int) or HttpServletResponse.sendError(int, String) if there is a reason and then returns an empty ModelAndView.

        Parameters:
        statusCode - the HTTP status code
        reason - the associated reason (may be null or empty)
        response - current HTTP response
        Throws:
        java.io.IOException
        Since:
        5.0