Using in spring 3 causes all other views to stop working

前端 未结 3 2079
无人共我
无人共我 2020-12-12 20:33

Simplest example:

I have a dispatcher servlet configured to catch everything:


    dispatcher         


        
3条回答
  •  再見小時候
    2020-12-12 21:05

    There are 2 problems:

    1. Never use /* in servlet mapping:

       
          dispatcher 
          / 
       
      
    2. requires (or explicitly declared handler mappings, etc).

      This happens because DispatcherServlet applies default configuration of handler mappings only when no custom handler mappings found in the context. Since adds its own handler mapping, defaults are broken, therefore other handler mappings should be decalred explicitly, either by or manually as beans.

      Also note that declares only DefaultAnnotationHandlerMapping and doesn't declare other mappings such as BeanNameUrlHandlerMapping, though they are in defaults of DispatcherServlet. Declare them manually if you need them.

提交回复
热议问题