使用curl发送 POST JSON

来源:互联网 发布:windows找不到regedit 编辑:程序博客网 时间:2024/04/29 13:06
使用出curl发送body时,需要加header -H 'Content-Type: application/json' ,否则content type就是application/x-www-form-urlencoded,那么这时候@RequestBody是接收不到的,而是@ModelAttribute 才能接收。curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":100}'http://localhost/test/adduser

0 0