Now we've got a basic idea of how request mapping works. I also mentioned that every web request first comes to the Dispatcher servlet, but the question is how does the Dispatcher servlet know it should handle every incoming request? The answer is we explicitly instructed it to do so through the getServletMappings
method of the DispatcherServletInitializer
class. Yes, when we return the string array containing only the "/
" character, it indicates the DispatcherServlet
configuration as the default servlet of the application. So every incoming request will be handled by DispatcherServlet
.
Let's observe what will happen when we change the return value of the getServletMappings
method.
Open
DispatcherServletInitializer
and change the return value of thegetServletMappings
method asreturn new String[] { "/app/*"}
; basically yourgetServletMappings
method should look like the following after your change...