org.springframework.boot.web.support

Class ErrorPageFilter

  • All Implemented Interfaces:
    javax.servlet.Filter, ErrorPageRegistry
    Direct Known Subclasses:
    ErrorPageFilter


    @Component
     @Order(value=-2147483648)
    public class ErrorPageFilter
    extends Object
    implements javax.servlet.Filter, ErrorPageRegistry
    A Servlet Filter that provides an ErrorPageRegistry for non-embedded applications (i.e. deployed WAR files). It registers error pages and handles application errors by filtering requests and forwarding to the error pages instead of letting the container handle them. Error pages are a feature of the servlet spec but there is no Java API for registering them in the spec. This filter works around that by accepting error page registrations from Spring Boot's ErrorPageRegistrar (any beans of that type in the context will be applied to this container).
    Since:
    1.4.0
    Author:
    Dave Syer, Phillip Webb, Andy Wilkinson
    • Field Detail

      • ERROR_REQUEST_URI

        public static final String ERROR_REQUEST_URI
        The name of the servlet attribute containing request URI.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ErrorPageFilter

        public ErrorPageFilter()
    • Method Detail

      • init

        public void init(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • doFilter

        public void doFilter(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException
      • addErrorPages

        public void addErrorPages(ErrorPage... errorPages)
        Description copied from interface: ErrorPageRegistry
        Adds error pages that will be used when handling exceptions.
        Specified by:
        addErrorPages in interface ErrorPageRegistry
        Parameters:
        errorPages - the error pages
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter

Copyright © 2017 Pivotal Software, Inc.. All rights reserved.