jersey / jackson POST到spring mvc - 糟糕的要求

时间:2016-11-23 08:13:50

标签: rest spring-mvc jersey jersey-2.0 jersey-client

Spring MVC中的REST:

@RequestMapping(value = "/something", method = RequestMethod.POST, headers = "Accept=application/json", produces = {"application/json"}, consumes = {"application/json"}) {
        public String createSomething(@RequestBody Simple simple) {
            return "";
}

我的实体类:

public class Simple {
    private String name;
 // plus default constructor, getter, setter
}

用衣服2来消耗REST:

WebTarget webTarget =  clientBuilder.build().target("http://localhost:8080/spring/something");
webTarget.request(MediaType.APPLICATION_JSON).post(Entity.entity(new Simple("example"), MediaType.APPLICATION_JSON), String.class);

这很好用。但是,一旦我将简单声明为:

public class Simple extends AnotherClass { .. }

我总是得到400 Bad请求。即使 AnotherClass 根本没有属性。

0 个答案:

没有答案