HttpClient
来源:互联网 发布:公文流转软件 编辑:程序博客网 时间:2024/06/09 23:25
public void sendPostRequestByForm(String path, String params) throws Exception{
CloseableHttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost(path);
post.setHeader(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");
StringEntity entity = new StringEntity(params,"UTF-8");
post.setEntity(entity);
CloseableHttpResponse response = client.execute(post);
CloseableHttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost(path);
post.setHeader(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");
StringEntity entity = new StringEntity(params,"UTF-8");
post.setEntity(entity);
CloseableHttpResponse response = client.execute(post);
}
public void test(){
//将实体转换成json格式
ObjectMapper mapper = new ObjectMapper();
sendPostRequestByForm(path,mapper.writeValueAsString(legacyUserDTO));
}
阅读全文
0 0
- HttpClient
- HttpClient
- httpClient
- HttpClient
- HttpClient
- HttpClient
- HttpClient
- HttpClient
- HttpClient
- HttpClient
- HttpClient
- httpclient
- httpclient
- HttpClient
- HttpClient
- httpclient
- httpclient
- HttpClient
- PAT (Advanced Level) Practise1133Splitting A Linked List (25)
- 有序的Map集合--LinkedHashMap
- JavaScript学习笔记_Reduce和Transduce
- 简单存储过程的编写
- java日期格式中MMM的问题
- HttpClient
- Python + opencv 实现图片马赛克
- log4net 使用笔记(c# .net framework)
- QObject::connect: Cannot queue arguments of type "xxx",(Make sure "xxx" is registed using qRegisterM
- 神奇的Invalid bound statement (not found)错误
- vector map set的使用
- PAT (Advanced Level) Practise1134Vertex Cover (25)
- CentOS中安装setup工具
- leetcode-cli的安装与使用以及未解决的问题