[英]JAXRS PUT-Request with Json from jquery --> 415
I try to make a simple put-request with a jquery-ajax-call.我尝试用 jquery-ajax-call 做一个简单的 put-request。 I try to pass a normal json object but each time I get error 415. The coding of the ajax call looks like the following:
我尝试传递一个普通的 json 对象,但每次我都会收到错误 415。ajax 调用的编码如下所示:
$.ajax(
type: "PUT",
contentType: "application/json",
url: myURL + "/UpdateUser/User/" + localStorage.getItem("user"),
dataType: "json",
data: model,
success: function(data, textStatus, jqXHR){
},
error: function(jqXHR, textStatus, errorThrown){
}
});
The model is a simple javascript variable with is converted into json.该模型是一个简单的 javascript 变量,它被转换为 json。 The JAXRS coding looks like the following:
JAXRS 编码如下所示:
@Path("/UpdateUser")
public class UpdateUser{
@PUT
@Path("/User/{user}")
@Consumes("application/json")
@Produces("application/json")
public String updateUser(@PathParam("user") String pUser, User pObject){
String return_val = "runs";
return(return_val);
}
}
Everytime when I run this code I get - as I already mentioned - the error 415. First I thought that I could have forgotten the content type ... but ... that was not the problem... I really hope that you can help me solving this problem!每次运行这段代码时,我都会得到 - 正如我已经提到的 - 错误 415。首先我以为我可能忘记了内容类型......但是......这不是问题......我真的希望你能帮我解决这个问题!
Greetings你好
As you did not provide enough information, I can only suppose what the problem is: Jersey is not configured to support JSON.由于您没有提供足够的信息,我只能假设问题是:Jersey 未配置为支持 JSON。 That is described in details here .
这是详细描述here 。 Besides more details to the problem you can probably find in the logs.
除了问题的更多详细信息,您可能还可以在日志中找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.