类 RelativeRedirectFilter
- java.lang.Object
- org.springframework.web.filter.GenericFilterBean
- org.springframework.web.filter.OncePerRequestFilter
- org.springframework.web.filter.RelativeRedirectFilter
- 所有已实现的接口:
Filter
,Aware
,BeanNameAware
,DisposableBean
,InitializingBean
,EnvironmentAware
,EnvironmentCapable
,ServletContextAware
public class RelativeRedirectFilter extends OncePerRequestFilter
OverridesHttpServletResponse.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.
- 从以下版本开始:
- 4.3.10
- 作者:
- Rob Winch, Rossen Stoyanchev
字段概要
从类继承的字段 org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
从类继承的字段 org.springframework.web.filter.GenericFilterBean
logger
构造器概要
构造器 构造器 说明 RelativeRedirectFilter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected 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.HttpStatus
getRedirectStatus()
Return the configured redirect status.void
setRedirectStatus(HttpStatus status)
Set the default HTTP Status to use for redirects.从类继承的方法 org.springframework.web.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
从类继承的方法 org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
构造器详细资料
RelativeRedirectFilter
public RelativeRedirectFilter()
方法详细资料
setRedirectStatus
public void setRedirectStatus(HttpStatus status)
Set the default HTTP Status to use for redirects.By default this is
HttpStatus.SEE_OTHER
.- 参数:
status
- the 3xx redirect status to use
getRedirectStatus
public HttpStatus getRedirectStatus()
Return the configured redirect status.
doFilterInternal
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException
从类复制的说明: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.