Class ErrorPageFilter
- java.lang.Object
- org.springframework.boot.web.servlet.support.ErrorPageFilter
- All Implemented Interfaces:
javax.servlet.Filter
,ErrorPageRegistry
@Order(-2147483647) public class ErrorPageFilter extends Object implements javax.servlet.Filter, ErrorPageRegistry
A ServletFilter
that provides anErrorPageRegistry
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 server 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'sErrorPageRegistrar
(any beans of that type in the context will be applied to this server).- Since:
- 2.0.0
Field Summary
Fields Modifier and Type Field Description static String
ERROR_REQUEST_URI
The name of the servlet attribute containing request URI.
Constructor Summary
Constructors Constructor Description ErrorPageFilter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addErrorPages(ErrorPage... errorPages)
Adds error pages that will be used when handling exceptions.void
destroy()
void
doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
protected String
getDescription(javax.servlet.http.HttpServletRequest request)
Return the description for the given request.void
init(javax.servlet.FilterConfig filterConfig)
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 interfacejavax.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 interfacejavax.servlet.Filter
- Throws:
IOException
javax.servlet.ServletException
getDescription
protected String getDescription(javax.servlet.http.HttpServletRequest request)
Return the description for the given request. By default this method will return a description based on the requestservletPath
andpathInfo
.- Parameters:
request
- the source request- Returns:
- the description
- Since:
- 1.5.0
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 interfaceErrorPageRegistry
- Parameters:
errorPages
- the error pages
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Filter