类 CorsFilter
java.lang.Object
cn.taketoday.web.servlet.filter.GenericFilterBean
cn.taketoday.web.servlet.filter.OncePerRequestFilter
cn.taketoday.web.servlet.filter.CorsFilter
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.beans.factory.DisposableBean,cn.taketoday.beans.factory.InitializingBean,cn.taketoday.context.ApplicationContextAware,cn.taketoday.context.EnvironmentAware,cn.taketoday.core.env.EnvironmentCapable,ServletContextAware,Filter
public class CorsFilter
extends OncePerRequestFilter
implements cn.taketoday.context.ApplicationContextAware
Filter that handles CORS preflight requests and intercepts
CORS simple and actual requests thanks to a CorsProcessor implementation
(DefaultCorsProcessor by default) in order to add the relevant CORS
response headers (like Access-Control-Allow-Origin) using the provided
CorsConfigurationSource- 从以下版本开始:
- 3.0
- 作者:
- Sebastien Deleuze, TODAY 2020/12/8 22:27
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private cn.taketoday.context.ApplicationContextprivate final CorsConfigurationSourceprivate CorsProcessor从类继承的字段 cn.taketoday.web.servlet.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX从类继承的字段 cn.taketoday.web.servlet.filter.GenericFilterBean
logger -
构造器概要
构造器构造器说明CorsFilter(CorsConfigurationSource configSource) Constructor accepting aCorsConfigurationSourceused by the filter to find theCorsConfigurationto use for each incoming request. -
方法概要
修饰符和类型方法说明protected voiddoFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) Same contract as fordoFilter, but guaranteed to be just invoked once per request within a single request thread.voidsetApplicationContext(cn.taketoday.context.ApplicationContext applicationContext) voidsetCorsProcessor(CorsProcessor processor) Configure a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request.从类继承的方法 cn.taketoday.web.servlet.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch从类继承的方法 cn.taketoday.web.servlet.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
字段详细资料
-
configSource
-
processor
-
applicationContext
@Nullable private cn.taketoday.context.ApplicationContext applicationContext
-
-
构造器详细资料
-
CorsFilter
Constructor accepting aCorsConfigurationSourceused by the filter to find theCorsConfigurationto use for each incoming request.
-
-
方法详细资料
-
setCorsProcessor
Configure a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request.By default
DefaultCorsProcessoris used. -
setApplicationContext
public void setApplicationContext(@Nullable cn.taketoday.context.ApplicationContext applicationContext) throws cn.taketoday.beans.BeansException - 指定者:
setApplicationContext在接口中cn.taketoday.context.ApplicationContextAware- 抛出:
cn.taketoday.beans.BeansException
-
doFilterInternal
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException 从类复制的说明:OncePerRequestFilterSame 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.
- 指定者:
doFilterInternal在类中OncePerRequestFilter- 抛出:
IOExceptionServletException
-