Advertisement
codeuniv

DispatcherServlet Mapping (Spring Boot)

Mar 29th, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Spring Boot provides the spring-boot-starter-web library for developing web applications using Spring MVC. One of the main features of Spring Boot is autoconfiguration. The Spring Boot autoconfiguration registers and configures the DispatcherServlet automatically. Therefore, we don’t need to register the DispatcherServlet manually.
  2.  
  3. By default, the spring-boot-starter-web starter configures DispatcherServlet to the URL pattern β€œ/”. So, we don't need to complete any additional configuration for the above DispatcherServlet example in the web.xml file. However, we can customize the URL pattern using server.servlet.* in the application.properties file:
  4.  
  5. server.servlet.context-path=/demo
  6. spring.mvc.servlet.path=/baeldung
  7.  
  8. DispatcherServlet is configured to handle the URL pattern /baeldung and the root contextPath will be /demo. Thus, DispatcherServlet listens at http://localhost:8080/demo/baeldung/.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement