适用于C Sharp的Easy Http库提供了一种将数据发布到url的方法,
var customer = new Customer();
customer.Name = "Joe";
customer.Email = "[email protected]";
var http = new HttpClient();
http.Post("url", customer, HttpContentTypes.ApplicationJson);
寻找一些库将数据发布到Java的URL。
您可以使用Apache的HTTPClientHTTP
在Java中创建基本操作。
例如,aPOST
看起来像这样:
HttpPost httpPost = new HttpPost("http://some-web-site");
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("name", "Joe"));
nvps.add(new BasicNameValuePair("email", "[email protected]"));
httPost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity result = response.getEntity();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句