2013-07-23 104 views
0

我有問題在澤西島數據庫上發佈多個@pathparams文件(沒有@pathparam測試,工作!!)。基於澤西島的@pathparm服務器的RESTful Android客戶端

服務器代碼:

@POST 
@Path("visit_add_image/{key}/{idvisita}/{body}/{img}/{img2}") 
@Produces(MediaType.TEXT_XML) 
@Consumes(MediaType.MULTIPART_FORM_DATA) 
public String visit_add_image( @FormDataParam("key")String key, 
           @FormDataParam("idvisita")Integer idvisita, 
           @FormDataParam("body")String body, 
           @FormDataParam("img")InputStream img, 
           @FormDataParam("img")FormDataContentDisposition imgDetail, 
           @FormDataParam("img2")InputStream img2, 
           @FormDataParam("img2")FormDataContentDisposition imgDetail2) throws SQLException{ 
    return ""; 
} 

而且客戶是這樣的:

HttpClient httpclient = new DefaultHttpClient(); 
     HttpPost httppost = new HttpPost(url../user/visit_add_image/11/111/112"); 


     FileBody fileContent= new FileBody(new File("/Users/Achron/Downloads/sun.jpg")); 
     FileBody fileContent2 = new FileBody(new File("/Users/Achron/Downloads/sun.jpg")); 
     MultipartEntity reqEntity = new MultipartEntity(); 

     reqEntity.addPart("img", fileContent); 
     reqEntity.addPart("img2", fileContent2); 
     httppost.setEntity(reqEntity); 
     HttpResponse response = null; 
     try { 
      response = httpclient.execute(httppost); 
      System.out.println("file "+response.toString()+""+" e stato inviato al server"); 
     } catch (ClientProtocolException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

而且不工作,因爲服務器的答案是404。任何人都知道該如何解決?

回答

0

您發佈的資源不同於您的@Path,這就是您收到404的原因。請確保您的HttpPost請求中包含正確數量的路徑元素。

相關問題