2
我從Android客戶端獲得多部分信息。我使用澤西web服務來接收多部分數據。我可以檢索多部分數據。但我無法使用@Context HttpServletRequest
請求獲取用戶標識。我的Android客戶端是,@context httpServletRequest針對澤西島郵政方法的請求爲空
HttpClient httpClient = new DefaultHttpClient();
Log.e("Picture Upload URL is:", QueryConfig.PROTOCOL+ StaticHelper.HOST + StaticHelper.port+QueryConfig.projectService+QueryConfig.sendProfilePicture);
HttpPost postRequest = new HttpPost(QueryConfig.PROTOCOL+ StaticHelper.HOST + StaticHelper.port+QueryConfig.projectService+QueryConfig.sendProfilePicture);
ByteArrayBody bab = new ByteArrayBody(data,StaticHelper.UserID+".jpg");
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("file", bab);
reqEntity.addPart("fileFilename",new StringBody(StaticHelper.UserID+".jpg"));
HttpResponse response = httpClient.execute(postRequest);
我的球衣服務
@Path("/mobileUserPictureInsert")
@POST
@Consumes("multipart/*")
@Produces(MediaType.APPLICATION_JSON)
public String save(@Context HttpServletRequest request, MultiPart multiPart)
throws ParseException {
BodyPartEntity bpeTokenId = (BodyPartEntity) multiPart.getBodyParts()
.get(2).getEntity();
try {
tokenId = getString(bpeTokenId.getInputStream());
String userId = "";
userId = getSession(tokenId, request);
的獲取會話方法是
protected String getSession(String token, HttpServletRequest req)
throws ServletException, IOException {
String value = (String) context.getAttribute(token);
LOG.info("Retrive Token Value-->" + value);
return value;
}
我在這裏請求傳遞和令牌生成檢索用戶ID。它適用於get方法。但是對於post方法,我得到空值。 pl幫助我。如何獲得澤西郵政方法的請求。