<mvc:annotation-driven />相当于在Spring MVC配置文件中,同时进行了以下三个配置:
<!-- 创建注解映射器 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"></bean>
<!-- 创建注解适配器 -->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<!-- 配置json格式支持 -->
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"></bean>
</list>
</property>
</bean>
本文详细解析了SpringMVC配置文件中<mvc:annotation-driven/>的作用, 它等价于创建了注解映射器与适配器,并配置了JSON格式的支持。通过具体代码展示了其如何实现RESTful风格的Web应用。
255

被折叠的 条评论
为什么被折叠?



