类 DelegatingFilterProxyRegistrationBean
- java.lang.Object
- org.springframework.boot.web.servlet.RegistrationBean
- org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean
- 所有已实现的接口:
org.springframework.beans.factory.Aware
,ServletContextInitializer
,org.springframework.context.ApplicationContextAware
,org.springframework.core.Ordered
public class DelegatingFilterProxyRegistrationBean extends RegistrationBean implements org.springframework.context.ApplicationContextAware
AServletContextInitializer
to registerDelegatingFilterProxy
s in a Servlet 3.0+ container. Similar to theregistration
features provided byServletContext
but with a Spring Bean friendly design.The bean name of the actual delegate
Filter
should be specified using thetargetBeanName
constructor argument. Unlike theFilterRegistrationBean
, referenced filters are not instantiated early. In fact, if the delegate filter bean is marked@Lazy
it won't be instantiated at all until the filter is called.Registrations can be associated with
URL patterns
and/or servlets (either byname
or via aServletRegistrationBean
s. When no URL pattern or servlets are specified the filter will be associated to '/*'. The targetBeanName will be used as the filter name if not otherwise specified.- 从以下版本开始:
- 1.4.0
- 另请参阅:
ServletContextInitializer
,ServletContext.addFilter(String, Filter)
,FilterRegistrationBean
,DelegatingFilterProxy
字段概要
字段 修饰符和类型 字段 说明 protected static int
REQUEST_WRAPPER_FILTER_MAX_ORDER
Filters that wrap the servlet request should be ordered less than or equal to this.
构造器概要
构造器 构造器 说明 DelegatingFilterProxyRegistrationBean(String targetBeanName, ServletRegistrationBean... servletRegistrationBeans)
Create a newDelegatingFilterProxyRegistrationBean
instance to be registered with the specifiedServletRegistrationBean
s.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addServletNames(String... servletNames)
Add servlet names for the filter.void
addServletRegistrationBeans(ServletRegistrationBean... servletRegistrationBeans)
AddServletRegistrationBean
s for the filter.void
addUrlPatterns(String... urlPatterns)
Add URL patterns that the filter will be registered against.protected void
configure(javax.servlet.FilterRegistration.Dynamic registration)
Configure registration settings.javax.servlet.Filter
getFilter()
Return theFilter
to be registered.Collection<String>
getServletNames()
Return a mutable collection of servlet names that the filter will be registered against.Collection<ServletRegistrationBean>
getServletRegistrationBeans()
Return a mutable collection of theServletRegistrationBean
that the filter will be registered against.protected String
getTargetBeanName()
Collection<String>
getUrlPatterns()
Return a mutable collection of URL patterns that the filter will be registered against.boolean
isMatchAfter()
Return if filter mappings should be matched after any declared Filter mappings of the ServletContext.void
onStartup(javax.servlet.ServletContext servletContext)
Configure the givenServletContext
with any servlets, filters, listeners context-params and attributes necessary for initialization.void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
void
setDispatcherTypes(EnumSet<javax.servlet.DispatcherType> dispatcherTypes)
Sets the dispatcher types that should be used with the registration.void
setDispatcherTypes(javax.servlet.DispatcherType first, javax.servlet.DispatcherType... rest)
Convenience method toset dispatcher types
using the specified elements.void
setMatchAfter(boolean matchAfter)
Set if the filter mappings should be matched after any declared filter mappings of the ServletContext.void
setServletNames(Collection<String> servletNames)
Set servlet names that the filter will be registered against.void
setServletRegistrationBeans(Collection<? extends ServletRegistrationBean> servletRegistrationBeans)
SetServletRegistrationBean
s that the filter will be registered against.void
setUrlPatterns(Collection<String> urlPatterns)
Set the URL patterns that the filter will be registered against.从类继承的方法 org.springframework.boot.web.servlet.RegistrationBean
addInitParameter, configure, getInitParameters, getOrDeduceName, getOrder, isAsyncSupported, isEnabled, setAsyncSupported, setEnabled, setInitParameters, setName, setOrder
字段详细资料
REQUEST_WRAPPER_FILTER_MAX_ORDER
protected static final int REQUEST_WRAPPER_FILTER_MAX_ORDER
Filters that wrap the servlet request should be ordered less than or equal to this.- 另请参阅:
- 常量字段值
构造器详细资料
DelegatingFilterProxyRegistrationBean
public DelegatingFilterProxyRegistrationBean(String targetBeanName, ServletRegistrationBean... servletRegistrationBeans)
Create a newDelegatingFilterProxyRegistrationBean
instance to be registered with the specifiedServletRegistrationBean
s.- 参数:
targetBeanName
- name of the target filter bean to look up in the Spring application context (must not benull
).servletRegistrationBeans
- associateServletRegistrationBean
s
方法详细资料
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- 指定者:
setApplicationContext
在接口中org.springframework.context.ApplicationContextAware
- 抛出:
org.springframework.beans.BeansException
getTargetBeanName
protected String getTargetBeanName()
getFilter
public javax.servlet.Filter getFilter()
Return theFilter
to be registered.- 返回:
- the filter
setServletRegistrationBeans
public void setServletRegistrationBeans(Collection<? extends ServletRegistrationBean> servletRegistrationBeans)
SetServletRegistrationBean
s that the filter will be registered against.- 参数:
servletRegistrationBeans
- the Servlet registration beans
getServletRegistrationBeans
public Collection<ServletRegistrationBean> getServletRegistrationBeans()
Return a mutable collection of theServletRegistrationBean
that the filter will be registered against.ServletRegistrationBean
s.- 返回:
- the Servlet registration beans
- 另请参阅:
setServletNames(java.util.Collection<java.lang.String>)
,setUrlPatterns(java.util.Collection<java.lang.String>)
addServletRegistrationBeans
public void addServletRegistrationBeans(ServletRegistrationBean... servletRegistrationBeans)
AddServletRegistrationBean
s for the filter.- 参数:
servletRegistrationBeans
- the servlet registration beans to add- 另请参阅:
setServletRegistrationBeans(java.util.Collection<? extends org.springframework.boot.web.servlet.ServletRegistrationBean>)
setServletNames
public void setServletNames(Collection<String> servletNames)
Set servlet names that the filter will be registered against. This will replace any previously specified servlet names.
getServletNames
public Collection<String> getServletNames()
Return a mutable collection of servlet names that the filter will be registered against.- 返回:
- the servlet names
addServletNames
public void addServletNames(String... servletNames)
Add servlet names for the filter.- 参数:
servletNames
- the servlet names to add
setUrlPatterns
public void setUrlPatterns(Collection<String> urlPatterns)
Set the URL patterns that the filter will be registered against. This will replace any previously specified URL patterns.
getUrlPatterns
public Collection<String> getUrlPatterns()
Return a mutable collection of URL patterns that the filter will be registered against.- 返回:
- the URL patterns
addUrlPatterns
public void addUrlPatterns(String... urlPatterns)
Add URL patterns that the filter will be registered against.- 参数:
urlPatterns
- the URL patterns
setDispatcherTypes
public void setDispatcherTypes(javax.servlet.DispatcherType first, javax.servlet.DispatcherType... rest)
Convenience method toset dispatcher types
using the specified elements.- 参数:
first
- the first dispatcher typerest
- additional dispatcher types
setDispatcherTypes
public void setDispatcherTypes(EnumSet<javax.servlet.DispatcherType> dispatcherTypes)
Sets the dispatcher types that should be used with the registration. If not specified the types will be deduced based on the value ofRegistrationBean.isAsyncSupported()
.- 参数:
dispatcherTypes
- the dispatcher types
setMatchAfter
public void setMatchAfter(boolean matchAfter)
Set if the filter mappings should be matched after any declared filter mappings of the ServletContext. Defaults tofalse
indicating the filters are supposed to be matched before any declared filter mappings of the ServletContext.- 参数:
matchAfter
- if filter mappings are matched after
isMatchAfter
public boolean isMatchAfter()
Return if filter mappings should be matched after any declared Filter mappings of the ServletContext.- 返回:
- if filter mappings are matched after
onStartup
public void onStartup(javax.servlet.ServletContext servletContext) throws javax.servlet.ServletException
从接口复制的说明:ServletContextInitializer
Configure the givenServletContext
with any servlets, filters, listeners context-params and attributes necessary for initialization.- 参数:
servletContext
- theServletContext
to initialize- 抛出:
javax.servlet.ServletException
- if any call against the givenServletContext
throws aServletException
configure
protected void configure(javax.servlet.FilterRegistration.Dynamic registration)
Configure registration settings. Subclasses can override this method to perform additional configuration if required.- 参数:
registration
- the registration