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。任何人都知道該如何解決?