PHP CURL与java http使用方法详解(2)

package web.app.controller; import tool.HttpRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import net.sf.json.JSONObject; @Controller @RequestMapping("Index") public class IndexController { @RequestMapping(value="index",method={RequestMethod.GET,RequestMethod.POST},produces="text/html;charset=utf-8") @ResponseBody public String index() { String sid = "1"; String apiUrl = "http://www.xxxxx.com/api/" +sid; String data = HttpRequest.get(apiUrl,null); //开始模拟浏览器请求 JSONObject json = JSONObject.fromObject(data); //解析返回的json数据结果 } }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/14f3aaf809bc7739bdac3f88dfe463d9.html