ServletRegistrationBean

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 onStartup. URL mapping can be configured used setUrlMappings or omitted when mapping to '/*' (unless alwaysMapUrl is set to false). The servlet name will be deduced if not specified.

Author

Phillip Webb

Since

1.4.0

Parameters

<T>

the type of the Servlet to register

See also

Constructors

Link copied to clipboard
constructor()
Create a new ServletRegistrationBean instance.
constructor(servlet: T, urlMappings: Array<String>)
Create a new ServletRegistrationBean instance with the specified Servlet and URL mappings.
constructor(servlet: T, alwaysMapUrl: Boolean, urlMappings: Array<String>)
Create a new ServletRegistrationBean instance with the specified Servlet and URL mappings.

Properties

Link copied to clipboard
private open var beanName: String
Link copied to clipboard
val HIGHEST_PRECEDENCE: Int = -2147483648
Link copied to clipboard
Link copied to clipboard
val LOWEST_PRECEDENCE: Int = 2147483647
Link copied to clipboard
open var multipartConfig: MultipartConfigElement
Link copied to clipboard
open var order: Int
Link copied to clipboard
open var servlet: T

Functions

Link copied to clipboard
open fun addInitParameter(name: String, value: String)
Add a single init-parameter, replacing any existing parameter with the same name.
Link copied to clipboard
open fun addUrlMappings(urlMappings: Array<String>)
Add URL mappings, as defined in the Servlet specification, for the servlet.
Link copied to clipboard
Returns the servlet name that will be registered.
Link copied to clipboard
Return a mutable collection of the URL mappings, as defined in the Servlet specification, for the servlet.
Link copied to clipboard
Returns if asynchronous operations are supported for this registration.
Link copied to clipboard
open fun isEnabled(): Boolean
Return if the registration is enabled.
Link copied to clipboard
fun onStartup(servletContext: ServletContext)
Configure the given ServletContext with any servlets, filters, listeners context-params and attributes necessary for initialization.
Link copied to clipboard
open fun setAsyncSupported(asyncSupported: Boolean)
Sets if asynchronous operations are supported for this registration.
Link copied to clipboard
open fun setEnabled(enabled: Boolean)
Flag to indicate that the registration is enabled.
Link copied to clipboard
open fun setIgnoreRegistrationFailure(ignoreRegistrationFailure: Boolean)
Sets whether registration failures should be ignored.
Link copied to clipboard
open fun setLoadOnStartup(loadOnStartup: Int)
Sets the loadOnStartup priority.
Link copied to clipboard
open fun setName(name: String)
Set the name of this registration.
Link copied to clipboard
open fun setUrlMappings(urlMappings: Collection<String>)
Set the URL mappings for the servlet.
Link copied to clipboard
open fun toString(): String