Springboot3 HttpUtil post、get请求

一、pom.xml

        
            cn.hutool
            hutool-all
            5.8.23
        

二、模拟post请求

顺便把header带上

        String baseUrl = "https://jisutrain.market.alicloudapi.com/train/ticket";

        String url = baseUrl+"?"+ "date="+trainQueryVO.getTime()+"&end="+trainQueryVO.getEndStation()+"&start="+trainQueryVO.getStartStation();

        HttpRequest post = HttpUtil.createPost(url);

        post.header("Authorization", "APPCODE d08cf285f3074e3a99288c");

        HttpResponse execute = post.execute();

三、模拟get请求

String url = "";

HttpRequest request = HttpRequest.get(url);

request.header(HttpRequest.HEADER_USER_AGENT, "mOZILLA/5.0")

request.PARAM("param", "value")

HttpRequest response = request.execute

你可能感兴趣的:(#,springboot,java,spring,boot)