类 ServletListenerRegistrationBean<T extends EventListener>
- java.lang.Object
- org.springframework.boot.web.servlet.RegistrationBean
- org.springframework.boot.web.servlet.ServletListenerRegistrationBean<T>
- 类型参数:
T
- the type of listener
- 所有已实现的接口:
ServletContextInitializer
,org.springframework.core.Ordered
public class ServletListenerRegistrationBean<T extends EventListener> extends RegistrationBean
AServletContextInitializer
to registerEventListener
s in a Servlet 3.0+ container. Similar to theregistration
features provided byServletContext
but with a Spring Bean friendly design. This bean can be used to register the following types of listener:ServletContextAttributeListener
ServletRequestListener
ServletRequestAttributeListener
HttpSessionAttributeListener
HttpSessionListener
ServletContextListener
- 从以下版本开始:
- 1.4.0
构造器概要
构造器 构造器 说明 ServletListenerRegistrationBean()
Create a newServletListenerRegistrationBean
instance.ServletListenerRegistrationBean(T listener)
Create a newServletListenerRegistrationBean
instance.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 T
getListener()
static Set<Class<?>>
getSupportedTypes()
Return the supported types for this registration.static boolean
isSupportedType(EventListener listener)
Returnstrue
if the specified listener is one of the supported types.void
onStartup(javax.servlet.ServletContext servletContext)
Configure the givenServletContext
with any servlets, filters, listeners context-params and attributes necessary for initialization.void
setListener(T listener)
Set the listener that will be registered.从类继承的方法 org.springframework.boot.web.servlet.RegistrationBean
addInitParameter, configure, getInitParameters, getOrDeduceName, getOrder, isAsyncSupported, isEnabled, setAsyncSupported, setEnabled, setInitParameters, setName, setOrder
构造器详细资料
ServletListenerRegistrationBean
public ServletListenerRegistrationBean()
Create a newServletListenerRegistrationBean
instance.
ServletListenerRegistrationBean
public ServletListenerRegistrationBean(T listener)
Create a newServletListenerRegistrationBean
instance.- 参数:
listener
- the listener to register
方法详细资料
setListener
public void setListener(T listener)
Set the listener that will be registered.- 参数:
listener
- the listener to register
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
getListener
public T getListener()
isSupportedType
public static boolean isSupportedType(EventListener listener)
Returnstrue
if the specified listener is one of the supported types.- 参数:
listener
- the listener to test- 返回:
- if the listener is of a supported type
getSupportedTypes
public static Set<Class<?>> getSupportedTypes()
Return the supported types for this registration.- 返回:
- the supported types