2016-02-29 80 views
0

我有一個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();  
    } 

可有人告訴我這是什麼樣的錯誤,我應該需要添加任何廣口瓶爲了這?

+2

檢查你的Response類,從你導入了哪個包?它應該是:'javax.ws.rs.core.Response' – ACV

+0

@ACV,我已經添加了,雖然它顯示相同的錯誤 – khanam

+0

我可以知道爲什麼投票下來嗎? – khanam

回答

0

試試這個: return Response.status(200).entity("your payload").build();

+0

ACV,當我添加上面的行時,它給出錯誤:方法狀態(int)未定義類型響應 – khanam

0

最後我解決了這個錯誤。 //Type 1: import javax.xml.ws.Response; Type2: import javax.ws.rs.core.Response;以前我使用Type1導入和評論類型1,我用Type2它得到解決。謝謝每個幫助我解決這個問題的人。