POSTMAN给出以下错误“服务器拒绝了此请求,因为请求实体的格式不受请求的资源支持”

时间:2017-07-26 09:43:04

标签: spring rest jackson

我知道错误的含义但无法调试它。

我的Bean类

public class User {

    private String name;
    private int age;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

}

我的控制器

@RequestMapping(value = "/user/create", method = RequestMethod.POST)
public ResponseEntity<Void> createUser(@RequestBody User user, UriComponentsBuilder ucBuilder) {
    System.out.println("Creating User " + user.getName());      
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(ucBuilder.path("/user/{id}").buildAndExpand(user.getName()).toUri());
    return new ResponseEntity<Void>(headers, HttpStatus.CREATED);
}

0 个答案:

没有答案