import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.util.HashMap; import java.util.Map; /** * @program: * @description: * @author: daijm * @create: 2022-07-11 15:10 */ public class test { public static void main(String[] args) throws Exception { //请求参数 Map<String, String> headers=new HashMap<>(); headers.put("startDate","2022-02-02"); headers.put("endDate","2022-02-02"); //请求地址 String requestURL="http://127.0.0.1:8070/in"; openUrl(requestURL,headers); } public static String openUrl(String url, Map<String,String> parameter) throws Exception { URL urls = new URL(url); HttpURLConnection connection = null; OutputStream outputStream = null; String rs = null; try { connection = (HttpURLConnection) urls.openConnection();
HttpURLConnection post请求“Content-Type“, “multipart/form-data“方式进行请求操作
最新推荐文章于 2023-03-20 21:23:06 发布