2017-11-09 09:21
@JFinal 波总,这些demo找到了,但是比如我想运行一下:
public void createUser() {
String json = "{\"userid\": \"Javen205\"," + "\"name\": \"Javen205\"," + "\"department\": [3],"
+ "\"position\": \"产品经理\"," + "\"mobile\": \"\"," + "\"gender\": \"1\"," + "\"email\": \"\","
+ "\"weixinid\": \"Javen205\","
// +"\"avatar_mediaid\":
// \"2-G6nrLmr5EC3MNb_-zL1dDdzkd0p7cNliYu9V5w7o8K0\","
+ "\"extattr\": {\"attrs\":[{\"name\":\"爱好\",\"value\":\"旅游\"},{\"name\":\"卡号\",\"value\":\"1234567234\"}]}}";
System.out.println(json);
ApiResult apiResult = ConUserApi.createUser(json);
renderText(apiResult.getJson());
}
应该放到哪里运行呢?
2017-07-24 14:09
@JFinal 波总,我需要填什么post的键才能让百度返回给我搜索的值呢?
public static void main(String[] args) {
String url = "http://www.baidu.com";
Map queryParas = new HashMap();
queryParas.put("appKey", "41B294F431CAF945ED204E6171759D15DA92A73E");
String ret = HttpKit.post(url, JSON.toJSONString(queryParas));
System.out.println(ret);
}
这个写的返回总是页面不存在。
波总帮帮忙啊
2017-07-24 11:09
@JFinal 波总,我用POST,
public static void main(String[] args) {
String url = "http://www.baidu.com";
Map queryParas = new HashMap();
queryParas.put("appKey", "41B294F431CAF945ED204E6171759D15DA92A73E");
String ret = HttpKit.post(url, JSON.toJSONString(queryParas));
System.out.println(ret);
}
给我返回的页面是页面不存在,应该怎么处理呢
2017-07-24 10:22
这是报错内容:
Exception in thread "main" java.lang.RuntimeException: java.net.MalformedURLException: no protocol: www.baidu.com
at test_kit.HttpKit.get(HttpKit.java:124)
at test_kit.HttpKit.get(HttpKit.java:134)
at test_kit.HttpKit.main(HttpKit.java:264)
Caused by: java.net.MalformedURLException: no protocol: www.baidu.com
at java.net.URL.(Unknown Source)
at java.net.URL.(Unknown Source)
at java.net.URL.(Unknown Source)
at test_kit.HttpKit.getHttpConnection(HttpKit.java:89)
at test_kit.HttpKit.get(HttpKit.java:119)
... 2 more
2017-07-24 10:20
@JFinal
public static void main(String[] args) {
String url = "www.baidu.com";
Map queryParas = new HashMap();
System.out.println(HttpKit.get(url, queryParas));
}
这样报错