本文共 1306 字,大约阅读时间需要 4 分钟。
@RequestMapping("/restful/post/{id}") @ResponseBody private static String restfullPost(@PathVariable String id) { final String uri = "http://inf.netkiller.cn/detail/html/{tid}/{cid}/{id}.html"; Mapparams = new HashMap (); params.put("tid", "2"); params.put("cid", "2"); params.put("id", id); City city = new City("Shenzhen", "Guangdong"); RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.postForObject(uri, city, String.class, params); return result; }
@RequestMapping("/findByMobile") public String findByMobile() { System.out.println("****************************findByMobile******************************"); final String uri = "http://www.netkiller.cn/account/getMemberByMobile.json"; MultiValueMapmap = new LinkedMultiValueMap (); try { map.add("prefix", "86"); map.add("mobile", "13698041116"); map.add("_pretty_", "false"); } catch (Exception e) { e.printStackTrace(); } RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.postForObject(uri, map, String.class); System.out.println(map.toString()); System.out.println(result); return result; }