Post的请求案例

1.简单的post请求案例

    $.post(rootPath+"/jasframework/loginLog/getStatisticsInfoByUserId.do",function(result){
        
        if(result!=null){
            var obj = JSON.parse(result);  //解析返回值 
            var name =  obj.userName;
             $("#users").html(name);
        }
    });

2.post请求方式2

 1 var url = rootPath+'/jasframework/ycsy/deletsoloution.do';
 2             $.post( url ,
 3                     {'eventid':rows[0].eventid},
 4                     function(result){
 5                         if (result.result) {
 6                             $.messager.alert(getLanguageValue("提示"),"删除成功!",'info');
 7                             $("#lablemange").datagrid('load'); //重新加载
 8                         } else {
 9                             $.messager.alert(getLanguageValue("error"),"删除失败!", 'info');
10                             return;
11                         }
12                     }
13                     ,'json');
14                 }
15             });

 

转载于:https://www.cnblogs.com/tian830937/p/4431805.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure! Here's an example of how to send a POST request using HttpClient in Java: ```java import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; public class HttpClientExample { public static void main(String[] args) { HttpClient httpClient = HttpClientBuilder.create().build(); HttpPost httpPost = new HttpPost("http://www.example.com/api/endpoint"); try { // Add request headers httpPost.setHeader("Content-Type", "application/json"); // Add request body String requestBody = "{\"key1\":\"value1\", \"key2\":\"value2\"}"; StringEntity stringEntity = new StringEntity(requestBody); httpPost.setEntity(stringEntity); // Send the POST request HttpResponse response = httpClient.execute(httpPost); // Get the response body HttpEntity responseEntity = response.getEntity(); String responseBody = EntityUtils.toString(responseEntity); // Print the response body System.out.println(responseBody); } catch (Exception e) { e.printStackTrace(); } } } ``` In this example, we're using the Apache HttpClient library to send a POST request to `http://www.example.com/api/endpoint`. We set the request headers, add the request body as a JSON string, and then execute the request using `httpClient.execute(httpPost)`. Finally, we retrieve the response body from the `HttpResponse` object and print it out. Remember to replace `http://www.example.com/api/endpoint` with the actual URL you want to send the POST request to, and modify the request headers and body according to your requirements.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值