【发布时间】:2015-01-05 11:48:03
【问题描述】:
我正在从 android 客户端获取多部分实体,如下所示。
HttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(
"http://localhost:9090/MBC_WS/rest/network/mobileUserPictureInsert1");
MultipartEntity reqEntity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("message", new StringBody("hi moni"));
postRequest.setEntity(reqEntity);
HttpResponse response = httpClient.execute(postRequest);
在球衣中,我试图检索消息但只获得对象。代码是:
@Path("/mobileUserPictureInsert1")
@POST
@Consumes("multipart/*")
public String create(MultiPart multiPart){
BodyPartEntity bpe = (BodyPartEntity) multiPart.getBodyParts().get(0).getEntity();
String message = bpe.toString();
在这里,我得到了一些对象,而不是消息值。我犯了什么错误。请帮助我。
【问题讨论】:
标签: java android jersey jersey-2.0