我正在尝试更新com.loopj.android:android-async-http的最新版本(1.4.9),其中org.apache.http被cz.msebera.android.httpclient替换。
现在我用:
StringEntity entity = new StringEntity("some data");
client.post(static_context, getAbsoluteUrl(url), entity, "application/json", responseHandler);所以我想我可以把它投给HttpEntity,但事实并非如此。
Caused by: java.lang.ClassCastException: org.apache.http.entity.StringEntity cannot be cast to cz.msebera.android.httpclient.HttpEntity因此,我的问题是如何使用数据创建HttpEntity,或者是否有更好的方法来创建包含体内数据的post请求?
发布于 2015-12-13 13:42:24
看起来您导入了错误的StringEntity类。
假设cz.msebera.android.httpclient仍然有一个StringEntity,您应该能够
import cz.msebera.android.httpclient.entity.StringEntity而不是
import org.apache.http.entity.StringEntityhttps://stackoverflow.com/questions/34251578
复制相似问题