谁能告诉我一个简单的例子,将 json 格式的数据从 android 发布到 asp mvc web 服务器?我用它来获取从 asp.net mvc 到 json 格式的 android 的数据:
new Thread() {
public void run() {
try{
JsonNode userData = null;
ObjectMapper mapper = new ObjectMapper();
HttpResponse res;
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost(URI.create("http://mylink.com/test/api"));
res = httpclient.execute(post);
userData = mapper.readValue(res.getEntity().getContent(), JsonNode.class);
name= (String)userData.get("name").getTextValue();
}catch(Exception e){
Log.e("activity","dead",e);
}
}
}.start();
editStatus.setText(name);
在 asp.net 中:
[HttpPost]
public ActionResult Api()
{
return Json(new { name = "test" });
}
它非常适合从 asp.net mvc Web 服务器获取数据,但是我如何将数据从 android 发送到 json 格式或其他格式的 asp.net mvc 控制器?