【问题标题】:how post file and string for HttpClient?如何为 HttpClient 发布文件和字符串?
【发布时间】:2011-09-20 09:04:23
【问题描述】:

我使用打击代码,发布文件和字符串,但响应错误代码 500。

Uri.Builder builder = new Uri.Builder();
              builder.path(AIRQ_POST_AIRQ);
              HttpPost post = new HttpPost(builder.build().toString());

              FileEntity imageEntity=new FileEntity(null,"multipart/form-data");

              StringEntity msgEntity = new StringEntity(msg,CharEncoding.UTF_8);
              StringEntity latEntity = new StringEntity(""+lat,CharEncoding.UTF_8);
              StringEntity lonEntity = new StringEntity(""+lon,CharEncoding.UTF_8);
              StringEntity typeEntity = new StringEntity(""+type,CharEncoding.UTF_8);
              StringEntity tagidEntity = new StringEntity(""+tagid,CharEncoding.UTF_8);
              StringEntity sourceEntity = new StringEntity(source,CharEncoding.UTF_8);

              post.setEntity(imageEntity);
              post.setEntity(msgEntity);
              post.setEntity(latEntity);
              post.setEntity(lonEntity);
              post.setEntity(typeEntity);
              post.setEntity(tagidEntity);
              post.setEntity(sourceEntity);

              sendAirQHttpTask(post,responseHandler);

【问题讨论】:

    标签: android string file post httpclient


    【解决方案1】:

    问题出在服务器端。如您所见,here500 表示Internal Server Error

    【讨论】:

      猜你喜欢
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-03
      • 1970-01-01
      • 2013-06-13
      • 1970-01-01
      相关资源
      最近更新 更多