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

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 headers = new HashMap(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+

你可能感兴趣的:(jfinal)