Class FilterRegistrationBean<T extends javax.servlet.Filter>
- java.lang.Object
- org.springframework.boot.web.servlet.RegistrationBean
- org.springframework.boot.web.servlet.DynamicRegistrationBean<javax.servlet.FilterRegistration.Dynamic>
- org.springframework.boot.web.servlet.AbstractFilterRegistrationBean<T>
- org.springframework.boot.web.servlet.FilterRegistrationBean<T>
- Type Parameters:
T
- the type ofFilter
to register
- All Implemented Interfaces:
ServletContextInitializer
,org.springframework.core.Ordered
public class FilterRegistrationBean<T extends javax.servlet.Filter> extends AbstractFilterRegistrationBean<T>
AServletContextInitializer
to registerFilter
s in a Servlet 3.0+ container. Similar to theregistration
features provided byServletContext
but with a Spring Bean friendly design.The
Filter
must be specified before callingRegistrationBean.onStartup(ServletContext)
. Registrations can be associated withURL 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 filter name will be deduced if not specified.- Since:
- 1.4.0
- See Also:
ServletContextInitializer
,ServletContext.addFilter(String, Filter)
,DelegatingFilterProxyRegistrationBean
Field Summary
Fields Modifier and Type Field Description static int
REQUEST_WRAPPER_FILTER_MAX_ORDER
Deprecated.since 2.1.0 in favor ofOrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER
Constructor Summary
Constructors Constructor Description FilterRegistrationBean()
Create a newFilterRegistrationBean
instance.FilterRegistrationBean(T filter, ServletRegistrationBean<?>... servletRegistrationBeans)
Create a newFilterRegistrationBean
instance to be registered with the specifiedServletRegistrationBean
s.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getFilter()
Return theFilter
to be registered.void
setFilter(T filter)
Set the filter to be registered.Methods inherited from class org.springframework.boot.web.servlet.AbstractFilterRegistrationBean
addRegistration, addServletNames, addServletRegistrationBeans, addUrlPatterns, configure, getDescription, getServletNames, getServletRegistrationBeans, getUrlPatterns, isMatchAfter, setDispatcherTypes, setDispatcherTypes, setMatchAfter, setServletNames, setServletRegistrationBeans, setUrlPatterns, toString
Methods inherited from class org.springframework.boot.web.servlet.DynamicRegistrationBean
addInitParameter, getInitParameters, getOrDeduceName, isAsyncSupported, register, setAsyncSupported, setInitParameters, setName
Methods inherited from class org.springframework.boot.web.servlet.RegistrationBean
getOrder, isEnabled, onStartup, setEnabled, setOrder
Field Detail
REQUEST_WRAPPER_FILTER_MAX_ORDER
@Deprecated public static final int REQUEST_WRAPPER_FILTER_MAX_ORDER
Deprecated.since 2.1.0 in favor ofOrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER
Filters that wrap the servlet request should be ordered less than or equal to this.- See Also:
- Constant Field Values
Constructor Detail
FilterRegistrationBean
public FilterRegistrationBean()
Create a newFilterRegistrationBean
instance.
FilterRegistrationBean
public FilterRegistrationBean(T filter, ServletRegistrationBean<?>... servletRegistrationBeans)
Create a newFilterRegistrationBean
instance to be registered with the specifiedServletRegistrationBean
s.- Parameters:
filter
- the filter to registerservletRegistrationBeans
- associateServletRegistrationBean
s
Method Detail
getFilter
public T getFilter()
Description copied from class:AbstractFilterRegistrationBean
Return theFilter
to be registered.- Specified by:
getFilter
in classAbstractFilterRegistrationBean<T extends javax.servlet.Filter>
- Returns:
- the filter