依赖注入
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
方法处理
public static void attendanceOption(String aaa) throws UnsupportedOperationException, IOException {
try {
CloseableHttpAsyncClient client = HttpAsyncClients.createDefault();
client.start();
final HttpPost post = new HttpPost("http://xxxxxxxxxxxxxxxxxon/update");
JSONObject param= new JSONObject();
param.put("aaa", ""+aaa+"");
//设置请求头 这里根据个人来定义
post.addHeader("Content-type", "application/json; charset=utf-8");
post.setHeader("Accept", "application/json");
StringEntity stringEntity = new StringEntity(param.toString());
post.setEntity(stringEntity);
//执行
try {
client.execute(post, null);
} catch (Exception e) {
e.printStackTrace();
System.out.println(e);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e);
}
}
调用方法
if(srceenList.size()>0){
try {
ChangeData.attendanceOption(aaa);
} catch (IOException e) {
e.printStackTrace();
}
}