🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 71.1 编写JSON REST服务 ### 71.1 编写JSON REST服务 只要添加的有Jackson2依赖,Spring Boot应用中的任何`@RestController`默认都会渲染为JSON响应,例如: ``` @RestController public class MyController { @RequestMapping("/thing") public MyThing thing() { return new MyThing(); } } ``` 只要`MyThing`能够通过Jackson2序列化(比如,一个标准的POJO或Groovy对象),默认[localhost:8080/thing](http://localhost:8080/thing)将响应一个JSON数据。有时在浏览器中你可能看到XML响应,因为浏览器倾向于发送XML accept headers。