Merge branch '2.0.x'

pull/14156/merge
Stephane Nicoll 6 years ago
commit 086fec09ef

@ -1326,12 +1326,22 @@ source for more details.
[[howto-switch-off-the-spring-mvc-dispatcherservlet]]
=== Switch Off the Spring MVC DispatcherServlet
Spring Boot wants to serve all content from the root of your application (`/`) down. If
you would rather map your own servlet to that URL, you can do it. However, you may lose
some of the other Boot MVC features. To add your own servlet and map it to the root
resource, declare a `@Bean` of type `Servlet` and give it the special bean name,
`dispatcherServlet`. (You can also create a bean of a different type with that name if
you want to switch it off and not replace it.)
By default, All content is served from the root of your application (`/`) down. If you
would rather map to a different path, you can configure one as follows:
[source,properties,indent=0,subs="verbatim"]
----
spring.mvc.servlet.path=/acme
----
If you have additional servlets you can declare a `@Bean` of type `Servlet` or
`ServletRegistrationBean` for each and Spring Boot will register them transparently to the
container. Because servlets are registered that way, they can be mapped to a sub-context
of the `DispatcherServlet` without invoking it.
Configuring the `DispatcherServlet` yourself is unusual but if you really need to do it, a
`@Bean` of type `DispatcherServletPath` must be provided as well to provide the path of
your custom `DispatcherServlet`.

Loading…
Cancel
Save