public void postdata() {
String url = "http://10.0.2.2:9102/post/scomment";
//实例化OkHttpClient对象
OkHttpClient client = new OkHttpClient();
//创建Post请求
RequestBody requestBody = new FormBody.Builder()
//添加数据
.add("articleId","sub")
.add("commentContent","添加数据")
.build();
//配置请求内容
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();
okhttp3.Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(okhttp3.Call call, IOException e) {
}
@Override
public void onResponse(okhttp3.Call call, Response response) throws IOException {
}
});
}

您的每一个用心回答,都会让这个世界变得更美好一些!