💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 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。