public class ErrorPageFilter extends java.lang.Object implements javax.servlet.Filter, ErrorPageRegistry, org.springframework.core.Ordered
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 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's ErrorPageRegistrar
(any
beans of that type in the context will be applied to this server).Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ERROR_REQUEST_URI
The name of the servlet attribute containing request URI.
|
Constructor and Description |
---|
ErrorPageFilter() |
Modifier and Type | Method and 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 java.lang.String |
getDescription(javax.servlet.http.HttpServletRequest request)
Return the description for the given request.
|
int |
getOrder() |
void |
init(javax.servlet.FilterConfig filterConfig) |
public static final java.lang.String ERROR_REQUEST_URI
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
javax.servlet.ServletException
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
java.io.IOException
javax.servlet.ServletException
protected java.lang.String getDescription(javax.servlet.http.HttpServletRequest request)
servletPath
and pathInfo
.request
- the source requestpublic void addErrorPages(ErrorPage... errorPages)
ErrorPageRegistry
addErrorPages
in interface ErrorPageRegistry
errorPages
- the error pagespublic void destroy()
destroy
in interface javax.servlet.Filter
public int getOrder()
getOrder
in interface org.springframework.core.Ordered