【发布时间】:2017-11-28 13:58:30
【问题描述】:
我想为更新函数传递一个 json 对象,但它不接受 json 对象并得到一个错误。错误是:
代码是:
(value = "/UpdateUser/", method = RequestMethod.PUT , consumes=MediaType.APPLICATION_JSON_VALUE)
public void UpdateUser(JSONObject RequiredObject)throws UnknownHostException {
// RequiredObject=new HashMap<>();
System.out.println("hello into update " + RequiredObject);
// readJSON.UpdateUser(RequiredObject);
}
【问题讨论】:
-
使用复制粘贴在表单中输入代码,选择它,然后点击顶部的
{},将其转换为可读的内容。不要使用图片。 -
{@RequestMapping(value = "/UpdateUser/", method = RequestMethod.PUT , consumes=MediaType.APPLICATION_JSON_VALUE) public void UpdateUser(JSONObject RequiredObject)throws UnknownHostException { // RequiredObject=new HashMap (); System.out.println("你好进入更新" + RequiredObject); // readJSON.UpdateUser(RequiredObject); }}
-
我已经编辑了这个问题给你一个例子。
-
您是否尝试过使用@RequestBody 以
JSONObject RequiredObject为前缀的注解?你也缺少@RequestMapping...最后你的变量不应该使用大写字母(但这是代码约定)
标签: json spring rest web-services