对象转换为json格式,类似中间层API

《一头扎进SpringMvc视频教程\《一头扎进SpringMvc》第四讲 源码\》

对象自动转换为json格式要在 spring-mvc.xml添加一个东西 ,和对应的命名空间引用和规范,和对应的jar包

<!-- 支持对象与json的转换。 -->
<mvc:annotation-driven/>  //注解驱动

提到目前已经引用了一堆很乱的jar包,maven时就简单了。

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">


<!-- 支持对象与json的转换。 -->
    <mvc:annotation-driven/>  

对应的jar包

jackson-annotations-2.2.1.jar
jackson-core-2.2.1.jar
jackson-core-asl-1.8.8.jar
jackson-databind-2.2.1.jar
jackson-mapper-asl-1.8.8.jar
jackson-module-jaxb-annotations-2.2.1.jar

 

posted @ 2017-06-19 20:33  海蓝7  阅读(258)  评论(0编辑  收藏  举报