spring mvc controller
@RequestMapping(method = RequestMethod.POST)
public Result<String> create(@Valid @RequestBody CouponModel model) {
//...
}
首先我称之为api
curl -X POST -d 'couponName=foo&couponPrice=30&...' 'http://localhost:8080/coupons'
Error 415 Unsupported Media Type
然后我修改@RequestMapping
注释以支持application/x-www-form-urlencoded
内容类型
@RequestMapping(method = RequestMethod.POST,consumes = {"application/x-www-form-urlencoded", "application/json"})
然后再打电话,
Error 415 Unsupported Media Type
为什么此consumes
属性不起作用?