当前位置: 首页 > 工具软件 > httpkit > 使用案例 >

JFinal之HttpKit发起post请求,请求Content-Type为application/json

叶光华
2023-12-01
package per.ty.http;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.jfinal.kit.HttpKit;

public class HttpKitTest {
    public static void main(String[] args) {
        JSONObject params = new JSONObject();
        params.put("key", "ty");

        Map<String, String> headers = new HashMap<String, String>(16);
        headers.put("Content-Type", "application/json");

        String ret = HttpKit.post("http://www.yilabao.com/api/user/add", null, params.toJSONString(),
                headers);

        System.out.println(ret);
    }
}

jfinal3.8+

 类似资料: