Java Webservice方法返回显示为编译类型错误?
问题描述:
我有一个Java的web服务方法,其中在地方的回报则显示为错误The method ok() is undefined for the type Response
这里是我的代码如下Java Webservice方法返回显示为编译类型错误?
@Path("/deleteMethod")
@GET
@Produces({"application/json"})
public Response deleteServiceMethod(@QueryParam("allPatients") boolean allPatients, @QueryParam("PatientName") String PatientName, @QueryParam("PatientPlace") String PatientPlace)
throws IOException, InterruptedException
{
//my logic is present here
return Response.ok().build();
}
可有人告诉我这是什么样的错误,我应该需要添加任何广口瓶为了这?
答
试试这个: return Response.status(200).entity("your payload").build();
+0
ACV,当我添加上面的行时,它给出错误:方法状态(int)未定义类型响应 – khanam
答
最后我解决了这个错误。 //Type 1: import javax.xml.ws.Response; Type2: import javax.ws.rs.core.Response;
以前我使用Type1导入和评论类型1,我用Type2它得到解决。谢谢每个帮助我解决这个问题的人。
检查你的Response类,从你导入了哪个包?它应该是:'javax.ws.rs.core.Response' – ACV
@ACV,我已经添加了,虽然它显示相同的错误 – khanam
我可以知道为什么投票下来吗? – khanam