Class ResourceUrlEncodingFilter
- java.lang.Object
- org.springframework.web.filter.GenericFilterBean
- org.springframework.web.servlet.resource.ResourceUrlEncodingFilter
- All Implemented Interfaces:
Filter
,Aware
,BeanNameAware
,DisposableBean
,InitializingBean
,EnvironmentAware
,EnvironmentCapable
,ServletContextAware
public class ResourceUrlEncodingFilter extends GenericFilterBean
A filter that wraps theHttpServletResponse
and overrides itsencodeURL
method in order to translate internal resource request URLs into public URL paths for external use.- Since:
- 4.1
- Author:
- Jeremy Grelle, Rossen Stoyanchev, Sam Brannen, Brian Clozel
Constructor Summary
Constructors Constructor Description ResourceUrlEncodingFilter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
ThedoFilter
method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
Constructor Detail
ResourceUrlEncodingFilter
public ResourceUrlEncodingFilter()
Method Detail
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException
Description copied from interface:javax.servlet.Filter
ThedoFilter
method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.A typical implementation of this method would follow the following pattern:
- Examine the request
- Optionally wrap the request object with a custom implementation to filter content or headers for input filtering
- Optionally wrap the response object with a custom implementation to filter content or headers for output filtering
- Either invoke the next entity in the chain using the FilterChain object (
chain.doFilter()
), - or not pass on the request/response pair to the next entity in the filter chain to block the request processing
- Either invoke the next entity in the chain using the FilterChain object (
- Directly set headers on the response after invocation of the next entity in the filter chain.
- Parameters:
request
- theServletRequest
object contains the client's requestresponse
- theServletResponse
object contains the filter's responsefilterChain
- theFilterChain
for invoking the next filter or the resource- Throws:
ServletException
- if an exception occurs that interferes with the filter's normal operationIOException
- if an I/O related error has occurred during the processing- See Also:
UnavailableException