Spring Boot中Rest接口POST如何接受JSON数据

近日在学习Spring Boot的过程中,按照教程构建了几个Rest接口,测试其中POST接口的时候发现用application/json请求的时候返回的均是null,而使用了application/x-www-form-urlencoded后可以得到正确结果。搜索到该文章《 @RequestMapping 用法详解之地址映射(转)》后,在@RequestMapping中增加 consumes = “application/json”,并将@ModelAttribute改成@RequestBody即可

 

Choosing an HTTP Status Code — Stop Making It Hard

这篇文章应该是我看过的解释如何选择http状态码的文章中写的最好的了。

原文(http://racksburg.com/choosing-an-http-status-code)

What could be simpler than returning HTTP status codes? Did the page render? Great, return 200. Does the page not exist? That’s a 404. Do I want to redirect the user to another page? 302, or maybe 301. 继续阅读