0

我正在尝试使用 RestTemplate 发布像 {"username":"mike", "password":"123"} 这样的 json。响应将只是 HTTP 200。

当我使用 curl 发布时,它可以工作,但是使用 RestTemplate 它显示 -

org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class model.User] from JSON String; no single-String constructor/factory method

httpHeaders.setContentType(MediaType.APPLICATION_JSON);
restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<String>(jsonString, httpHeaders), String.class);

我用 Jackson 和 Gson 制作了我的“jsonString”,它看起来与上面显示的相同。(Spring 3.2.2,杰克逊映射器和 asl 1.9.3)

任何人都可以帮忙吗?

4

0 回答 0