public static ReturnMsg> tripartite(String token) throws JsonProcessingException { String urlTemp="url"; ReturnMsg> returnMsg = new ReturnMsg<>(0, "请求第三方 成功)"); StringBuilder json = new StringBuilder(); try { URL httpurl= new URL(urlTemp); URLConnection yc = httpurl.openConnection();//打开链接 yc.setRequestProperty("token",token); BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream(), "utf-8"));// 防止乱码 String inputLine = null; while ((inputLine = in.readLine()) != null) { json.append(inputLine); } in.close(); } catch (MalformedURLException e) {//http协议异常 } catch (IOException e) {//读取异常 } returnMsg.setData(ParseDataUtil.getObjectMapper().readValue(json.toString(), new TypeReference>() { })); return returnMsg; }
上一篇 SpringBoot总结
下一篇 【解决】无法在web.xml或使用此应用程序部署的jar文件中解析绝对uri:[http://java.sun.com/jsp/jstl/core]
版权所有 (c)2021-2022 MSHXW.COM
ICP备案号:晋ICP备2021003244-6号