上面代码无格式,补充代码[代码]public[代码] [代码]static[代码] [代码]void[代码] [代码]main(String[] args) {[代码][代码] [代码][代码]String url = [代码][代码]"https://api.weixin.qq.com/sns/jscode2session?appid=appid&secret=secret&js_code=js_code&grant_type=authorization_code"[代码][代码];[代码][代码] [代码][代码]RestTemplate restTemplate = [代码][代码]new[代码] [代码]RestTemplate();[代码][代码] [代码][代码]//进行网络请求,访问url接口[代码][代码] [代码][代码]ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, [代码][代码]null[代码][代码], String.[代码][代码]class[代码][代码]);[代码][代码] [代码][代码]if[代码][代码](responseEntity != [代码][代码]null[代码] [代码]&& responseEntity.getStatusCode() == HttpStatus.OK) {[代码][代码] [代码][代码]String sessionData = responseEntity.getBody();[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码]
JAVA后台登陆连接超时- 当前 Bug 的表现(可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo java调用小程序报错如下: I/O error on GET request for "https://api.weixin.qq.com/sns/jscode2session": Connection timed out: connect 代码如下: public static void main(String[] args) { String url = "https://api.weixin.qq.com/sns/jscode2session?appid=appid&secret=secret&js_code=js_code&grant_type=authorization_code"; RestTemplate restTemplate = new RestTemplate(); //进行网络请求,访问url接口 ResponseEntityresponseEntity = restTemplate.exchange(url, HttpMethod.GET, null, String.class); if(responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) { String sessionData = responseEntity.getBody(); } }
2019-04-16