1. 自動封裝返回對象爲JSONspring
1).在spring配置文件中添加以下配置:json
<mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.json.GsonHttpMessageConverter"/> </mvc:message-converters> </mvc:annotation-driven>
2).在須要進行轉化的Controller上添加 @RestController 或method上添加@ResponseBody註解mvc