對象轉換為json格式,類似中間層API
阿新 • • 發佈:2017-06-19
-- 簡單 xmlns 支持 ota org div bsp jackson
《一頭紮進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/contexthttp://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
對象轉換為json格式,類似中間層API