[英]how to receive parameters with a PUT method in java web service
So I have asked this question with the return type . 所以我用返回类型问了这个问题。
Now i try to make a PUT
method like this: 现在我尝试制作这样的
PUT
方法:
@PUT
@Path("deleteAbsence")
@Produces("text/html")
public Response deleteAbsence(@QueryParam("id") String absenceID) {
String data = null;
return Response.ok("asda {"+absenceID+"}").build();
}
And my absenceID
is null
. 我的
absenceID
是null
。 What do I have to change to receive the parameter? 我需要更改什么来接收参数?
here is the answer i receive from the server with error 415: response 这是我从服务器收到的答案,错误415: 响应
将PUT请求发送到http://example.com/deleteAbsence/?id=42
使用正确的查询参数调用资源:
PUT http://example.com/deleteAbsence/?id=42
in the content i had to put: 在我必须放的内容:
"<"absenceIDString >2 "<"/absenceIDString>
and the method looks like this: 这个方法看起来像这样:
@Consumes("application/xml")
@PUT
@Path("deleteAbsence")
@Produces("text/html")
public Response deleteAbsence( String absenceIDString) {
String data = null;
return Response.ok("asda {"+absenceIDString+"}").build();
}
It is something to do with your Rest Web Service Explorer configuration in MyEclipse. 它与MyEclipse中的Rest Web Service Explorer配置有关。 The screenshot shows your variable name as
absenseIdString
while it should be id
. 屏幕截图显示您的变量名称为
absenseIdString
而它应该是id
。 Make sure that you have configured the Param Type as QueryParam
. 确保已将Param Type配置为
QueryParam
。 In myeclispe config screen, default value is PathParam. 在myeclispe配置屏幕中,默认值为PathParam。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.