类 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.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 protected String
getDescription()
Return a description of the registration.T
getListener()
Return the listener to be registered.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.protected void
register(String description, javax.servlet.ServletContext servletContext)
Register this bean with the servlet context.void
setListener(T listener)
Set the listener that will be registered.从类继承的方法 org.springframework.boot.web.servlet.RegistrationBean
getOrder, isEnabled, onStartup, setEnabled, 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
getListener
public T getListener()
Return the listener to be registered.- 返回:
- the listener to be registered
getDescription
protected String getDescription()
从类复制的说明:RegistrationBean
Return a description of the registration. For example "Servlet resourceServlet"- 指定者:
getDescription
在类中RegistrationBean
- 返回:
- a description of the registration
register
protected void register(String description, javax.servlet.ServletContext servletContext)
从类复制的说明:RegistrationBean
Register this bean with the servlet context.- 指定者:
register
在类中RegistrationBean
- 参数:
description
- a description of the item being registeredservletContext
- the servlet context
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