retrofit2.0 post提交一直返回400,用httpurlconnection就可以
1.用retrofit2.0 post提交 json
@POST("AppLoginIn")
Call getLoginUser(@Body String parameterJson);
//待提交的json数据
private String toJsonUser() {
JSONStringer jsonStringer = null;
try {
jsonStringer = new JSONStringer().object().key("LoginCode").value("SUPERMAN").key("Password")
.value("111111").endObject();
} catch (JSONException e) {
e.printStackTrace();
}
Log.i("", "---json user:" + jsonStringer.toString());
return jsonStringer.toString();
}
//retrofit 请求
private void postYDL(String jsonString) {
Retrofit retrofit = new Retrofit.Builder().baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build();
IService iService = retrofit.create(IService.class);
Call call = iService.getLoginUser(jsonString);
call.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
String responseData = "---body:" + response.body()
"n---message:" + response.message()
"n---headers:" + response.headers()
"n---code:" + response.code()
"n---isSuccessful:" + response.isSuccessful();
Log.i("", "---base action responseData:" + responseData);
tv1.setText(responseData);
}
@Override
void onFailure(Call call, Throwable t) {
tv1.setText(t.getMessage());
}
});
}
换另一个请求地址结果:
相关阅读:
GSAP js动画性能优于jQuery的原理是什么?
flask-restful拿url上的的参数
div中的文字不换行
2个DatePicker怎么进行验证,下面的一定要比上面的时间大?
PHP 如何快速判断远程文件是否存在
python3 导入logging出错
a标签的点击事件和button的点击事件的区别
如何理解JS的异步加载数据
iOS 如何获取相册中的视频并把视频路径保存在Documents中。
v4中的PageAdapter的destroyItem,instantiateItem方法显示过时
通常我们点击刷新,或者跳转页面页面的状态就会丢失,如何保存用户的访问状态
pip安装uwsgi时,如何指定使用特定的pcre安装路径
yii 目的是想在视图里创建变量(保护php的代码),然后,在js文件里调用之前创建的变量
for循环存取数据到文件中
安装uwsgi时报错
在页面中,除了xmp,textarea以及js转义外,还有什么办法可以让html标签在不被浏览器解析而正常显示呢?
webpack 热加载,更改局部文件会整体编译一次?
eclipse jsp 注释问题?
手册中语法说明的方括号怎么理解?
PHP一个数组的排序的问题