spring mvc RequestMapping注释使用配置不起作用

时间:2016-04-03 07:22:24

标签: spring-mvc content-type

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属性不起作用?

0 个答案:

没有答案