public class DefaultServletHandlerConfigurer extends Object
DispatcherServlet is mapped to "/"
thus overriding the Servlet container's default handling of static resources.
Since this handler is configured at the lowest precedence, effectively it allows all other handler mappings to handle the request, and if none of them do, this handler can forward it to the "default" Servlet.
DefaultServletHttpRequestHandler| Constructor and Description |
|---|
DefaultServletHandlerConfigurer(ServletContext servletContext)
Create a
DefaultServletHandlerConfigurer instance. |
| Modifier and Type | Method and Description |
|---|---|
protected SimpleUrlHandlerMapping |
buildHandlerMapping()
Return a handler mapping instance ordered at
Ordered.LOWEST_PRECEDENCE
containing the DefaultServletHttpRequestHandler instance mapped
to "/**"; or null if default servlet handling was not
enabled. |
void |
enable()
Enable forwarding to the "default" Servlet.
|
void |
enable(String defaultServletName)
Enable forwarding to the "default" Servlet identified by the given name.
|
public DefaultServletHandlerConfigurer(ServletContext servletContext)
DefaultServletHandlerConfigurer instance.servletContext - the ServletContext to use.public void enable()
When this method is used the DefaultServletHttpRequestHandler
will try to autodetect the "default" Servlet name. Alternatively, you can
specify the name of the default Servlet via enable(String).
DefaultServletHttpRequestHandlerpublic void enable(@Nullable String defaultServletName)
This is useful when the default Servlet cannot be autodetected, for example when it has been manually configured.
DefaultServletHttpRequestHandler@Nullable protected SimpleUrlHandlerMapping buildHandlerMapping()
Ordered.LOWEST_PRECEDENCE
containing the DefaultServletHttpRequestHandler instance mapped
to "/**"; or null if default servlet handling was not
enabled.