1. 程式人生 > >The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

今天遇到一個問題,

原因是@Controller註釋未生效,需在xml新增<mvc:annotation-driven />

<mvc:annotation-driven/>相當於註冊了DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter

這兩個bean,配置一些messageconverter。

所以當我們需要controller返回一個map的json物件時,一定要設定<mvc:annotation-driven />