类 ServletRegistrationBean<T extends Servlet>
java.lang.Object
org.springframework.boot.web.servlet.RegistrationBean
org.springframework.boot.web.servlet.DynamicRegistrationBean<ServletRegistration.Dynamic>
org.springframework.boot.web.servlet.ServletRegistrationBean<T>
- 类型参数:
T- the type of theServletto register
- 所有已实现的接口:
Aware,BeanNameAware,ServletContextInitializer,Ordered
public class ServletRegistrationBean<T extends Servlet>
extends DynamicRegistrationBean<ServletRegistration.Dynamic>
A
ServletContextInitializer to register Servlets in a Servlet 3.0+
container. Similar to the registration features provided by ServletContext but with a Spring Bean
friendly design.
The servlet must be specified before calling
RegistrationBean.onStartup(jakarta.servlet.ServletContext). URL mapping can be configured used setUrlMappings(java.util.Collection<java.lang.String>) or
omitted when mapping to '/*' (unless
alwaysMapUrl is set to
false). The servlet name will be deduced if not specified.
- 从以下版本开始:
- 1.4.0
- 作者:
- Phillip Webb
- 另请参阅:
-
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
构造器概要
构造器构造器说明Create a newServletRegistrationBeaninstance.ServletRegistrationBean(T servlet, boolean alwaysMapUrl, String... urlMappings) Create a newServletRegistrationBeaninstance with the specifiedServletand URL mappings.ServletRegistrationBean(T servlet, String... urlMappings) Create a newServletRegistrationBeaninstance with the specifiedServletand URL mappings. -
方法概要
修饰符和类型方法说明protected ServletRegistration.DynamicaddRegistration(String description, ServletContext servletContext) voidaddUrlMappings(String... urlMappings) Add URL mappings, as defined in the Servlet specification, for the servlet.protected voidconfigure(ServletRegistration.Dynamic registration) Configure registration settings.protected StringReturn a description of the registration.Returns themulti-part configurationto be applied ornull.Return the servlet being registered.Returns the servlet name that will be registered.Return a mutable collection of the URL mappings, as defined in the Servlet specification, for the servlet.voidsetLoadOnStartup(int loadOnStartup) Sets theloadOnStartuppriority.voidsetMultipartConfig(MultipartConfigElement multipartConfig) Set themulti-part configuration.voidsetServlet(T servlet) Sets the servlet to be registered.voidsetUrlMappings(Collection<String> urlMappings) Set the URL mappings for the servlet.toString()从类继承的方法 org.springframework.boot.web.servlet.DynamicRegistrationBean
addInitParameter, getInitParameters, getOrDeduceName, isAsyncSupported, register, setAsyncSupported, setBeanName, setIgnoreRegistrationFailure, setInitParameters, setName从类继承的方法 org.springframework.boot.web.servlet.RegistrationBean
getOrder, isEnabled, onStartup, setEnabled, setOrder
-
构造器详细资料
-
ServletRegistrationBean
public ServletRegistrationBean()Create a newServletRegistrationBeaninstance. -
ServletRegistrationBean
Create a newServletRegistrationBeaninstance with the specifiedServletand URL mappings.- 参数:
servlet- the servlet being mappedurlMappings- the URLs being mapped
-
ServletRegistrationBean
Create a newServletRegistrationBeaninstance with the specifiedServletand URL mappings.- 参数:
servlet- the servlet being mappedalwaysMapUrl- if omitted URL mappings should be replaced with '/*'urlMappings- the URLs being mapped
-
-
方法详细资料
-
setServlet
Sets the servlet to be registered.- 参数:
servlet- the servlet
-
getServlet
Return the servlet being registered.- 返回:
- the servlet
-
setUrlMappings
Set the URL mappings for the servlet. If not specified the mapping will default to '/'. This will replace any previously specified mappings.- 参数:
urlMappings- the mappings to set- 另请参阅:
-
getUrlMappings
Return a mutable collection of the URL mappings, as defined in the Servlet specification, for the servlet.- 返回:
- the urlMappings
-
addUrlMappings
Add URL mappings, as defined in the Servlet specification, for the servlet.- 参数:
urlMappings- the mappings to add- 另请参阅:
-
setLoadOnStartup
public void setLoadOnStartup(int loadOnStartup) Sets theloadOnStartuppriority. SeeServletRegistration.Dynamic.setLoadOnStartup(int)for details.- 参数:
loadOnStartup- if load on startup is enabled
-
setMultipartConfig
Set themulti-part configuration.- 参数:
multipartConfig- the multipart configuration to set ornull
-
getMultipartConfig
Returns themulti-part configurationto be applied ornull.- 返回:
- the multipart config
-
getDescription
从类复制的说明:RegistrationBeanReturn a description of the registration. For example "Servlet resourceServlet"- 指定者:
getDescription在类中RegistrationBean- 返回:
- a description of the registration
-
addRegistration
protected ServletRegistration.Dynamic addRegistration(String description, ServletContext servletContext) -
configure
Configure registration settings. Subclasses can override this method to perform additional configuration if required.- 覆盖:
configure在类中DynamicRegistrationBean<ServletRegistration.Dynamic>- 参数:
registration- the registration
-
getServletName
Returns the servlet name that will be registered.- 返回:
- the servlet name
-
toString
-