springMVC配置Json


步驟1:將json包引入工程中,分別是:jackson-annotations-2.7.0.jar,jackson-core-2.7.0.jar,jackson-databind-2.7.0.jar

步驟2:配置springmvc的配置文件,也就是配置JSON解析器,代碼如下:

    <mvc:annotation-driven>
         <mvc:message-converters>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
           </mvc:message-converters>
       </mvc:annotation-driven>

然后可以正常傳遞json對象的數據了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM