
我正在点击的网络服务需要参数为URLEncodedFormEntity.我无法根据Web服务的要求更改空间,而是将空间转换为.
我的代码是:
httpClIEnt clIEnt = new DefaulthttpClIEnt()httpPost post = new httpPost(url);UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters, http.UTF_8);post.setEntity(entity);httpResponse resp = clIEnt.execute(post);其中参数是List< nameValuePair>参数.
我阅读了很多帖子,并且都建议在动画之后将manuall更改为空间.在这里,我如何访问实体并手动更改它?
任何帮助将不胜感激.
解决方法:
UrlEncodedFormEntity基本上是一个带有自定义构造函数的StringEntity,您实际上不必使用它来创建可用的实体.
String entityValue = URLEncodedUtils.format(parameters, http.UTF_8);// Do your replacement here in entityValueStringEntity entity = new StringEntity(entityValue, http.UTF_8);entity.setContentType(URLEncodedUtils.CONTENT_TYPE);// And Now do your posting of this entity 总结 以上是内存溢出为你收集整理的android – 如何在执行apache HttpPost时对UrlEncodedFormEntity中的空间进行编码?全部内容,希望文章能够帮你解决android – 如何在执行apache HttpPost时对UrlEncodedFormEntity中的空间进行编码?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)