admin 管理员组文章数量: 887609
2024年1月10日发(作者:go语言入门开源项目)
t(reqUrl, "请求地址为空"); t(params, "请求数据为空"); } catch (Exception e) { throw new Exception("发送请求参数为空:" + sage(), e); } String request = params ;//发送服务端数据 HttpURLConnection httpConnection = null; try { httpConnection = (HttpURLConnection) new URL(reqUrl) .openConnection(); uestMethod("POST"); utput(true); nput(true); Caches(false); uestProperty("Connection", "Keep-Alive"); uestProperty("Charset", yName()); uestProperty("Content-Type", "application/json; charset=" + yName()); uestProperty("accept", "application/json"); dTimeout(readTimeSec * 1000);// 设置http连接的读超时,单位是毫秒 nectTimeout(connTimeSec * 1000); // 1、连接 try { t(); } catch (Exception e) { throw new Exception( "服务器连接是失败"); } OutputStream outwritestream = null; // 2、发送数据 try { //n("请求数据:"+request); byte[] writebytes = es(charset); outwritestream = putStream(); (writebytes); (); } catch (Exception e) { throw new Exception( "请求数据发送失败", e); } finally { try { (); } catch (Exception e) { } } return getHttpReturn(httpConnection , charset); } catch (Exception e) { throw new Exception("服务器连接失败:" + sage(), e); } finally { if (httpConnection != null) { nect(); } } }
/** * @param httpConnection
* @return Http连接返回数据转化成字符串 * @throws Exception */ private static String getHttpReturn(HttpURLConnection httpConnection , Charset charset) throws Exception { int responseCode = -1; try {
版权声明:本文标题:Redis——项目使用:缓存数据(一) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1704897767h466115.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论