Package org.springframework.web.filter
Class RelativeRedirectFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.springframework.web.filter.RelativeRedirectFilter
- All Implemented Interfaces:
Filter
,Aware
,BeanNameAware
,DisposableBean
,InitializingBean
,EnvironmentAware
,EnvironmentCapable
,ServletContextAware
Overrides
HttpServletResponse.sendRedirect(String)
and handles it by
setting the HTTP status and "Location" headers, which keeps the Servlet
container from re-writing relative redirect URLs into absolute ones.
Servlet containers are required to do that but against the recommendation of
RFC 7231 Section 7.1.2,
and furthermore not necessarily taking into account "X-Forwarded" headers.
Note: While relative redirects are recommended in the RFC, under some configurations with reverse proxies they may not work.
- Since:
- 4.3.10
- Author:
- Rob Winch, Rossen Stoyanchev
-
Field Summary
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doFilterInternal
(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) Same contract as fordoFilter
, but guaranteed to be just invoked once per request within a single request thread.Return the configured redirect status.void
setRedirectStatus
(HttpStatus status) Set the default HTTP Status to use for redirects.Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
Constructor Details
-
RelativeRedirectFilter
public RelativeRedirectFilter()
-
-
Method Details
-
setRedirectStatus
Set the default HTTP Status to use for redirects.By default this is
HttpStatus.SEE_OTHER
.- Parameters:
status
- the 3xx redirect status to use
-
getRedirectStatus
Return the configured redirect status. -
doFilterInternal
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException Description copied from class:OncePerRequestFilter
Same contract as fordoFilter
, but guaranteed to be just invoked once per request within a single request thread. SeeOncePerRequestFilter.shouldNotFilterAsyncDispatch()
for details.Provides HttpServletRequest and HttpServletResponse arguments instead of the default ServletRequest and ServletResponse ones.
- Specified by:
doFilterInternal
in classOncePerRequestFilter
- Throws:
ServletException
IOException
-