Variables in class DispatcherServlet
private List<HandlerAdapter> handlerAdapters;
From: http://www.cnblogs.com/hujingwei/p/5349983.html
When I was working on the project, I hoped that the static resources would be handled by the default Servlet of the web server, so I added the following statement to the configuration file:
<mvc:default-servlet-handler/>
But when I ran the project again and accessed the resources, I found that the access to @RequestMapping("/path1/path2") was inaccessible, and it was accessible when it was not added before.
The solution is to add another line of code to the configuration file:
<mvc:annotation-driven/>
The reason for this is:
When there are no two tags, the framework registers the bean AnnotationMethodHandlerAdapter by default, so it can process the @RequestMapping annotation, but only the three beans registered when <mvc:default-servlet-handler/> is configured cannot be processed. @RequestMapping annotation, so the corresponding Controller cannot be found, and the access path mapping cannot be performed. When both tags are present, <mvc:annotation-driven/> will register a RequestMappingHandlerAdapter bean, which can handle @RequestMapping. annotation.