当前位置: 首页 > news >正文

用织梦做网站还要不要服务器长沙seo

用织梦做网站还要不要服务器,长沙seo,wordpress transient,网站制作方案包括哪些内容一、远程调用post接口时的方法 方法一#xff1a; 这个方式的querys传的是参数#xff08;参数可是单个参数/对象#xff09; host指的是远程调用的主机地址 headers指的是头信息#xff08;可有可无#xff09; body指的是字符集的编码格式 public static String doPo…一、远程调用post接口时的方法 方法一 这个方式的querys传的是参数参数可是单个参数/对象 host指的是远程调用的主机地址 headers指的是头信息可有可无 body指的是字符集的编码格式 public static String doPost(String host, String path,MapString, String headers,MapString, String querys,String body)throws Exception {HttpClient httpClient wrapClient(host);HttpPost request new HttpPost(buildUrl(host, path, querys));for (Map.EntryString, String e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (body!null !.equals(body) body.length()0) {request.setEntity(new StringEntity(body, utf-8));}//客户端执行。获取数据HttpResponse response httpClient.execute(request);//通过response里的getEntity()方法获取客户端的返回值然后return进行返回HttpEntity entity (HttpEntity) response.getEntity();if (entity ! null) {body EntityUtils.toString(entity, UTF-8);}//json根据key取valueEntityUtils.consume(entity);return body;}方法二 urlStr 第三方接口地址 param 数据参数JSON格式可以为null这个一般传的是对象参数 public static String doPost(String urlStr, String param) {HttpURLConnection connection null;InputStream is null;InputStreamReader rsd null;BufferedReader br null;OutputStream os null;OutputStreamWriter osw null;BufferedWriter bw null;StringBuffer sb new StringBuffer();try {URL url new URL(urlStr);connection (HttpURLConnection) url.openConnection();connection.setRequestMethod(POST);connection.setDoInput(true);connection.setDoOutput(true);connection.setUseCaches(false); //不缓存connection.setRequestProperty(connection, Keep-Alive); //设置保活连接connection.setRequestProperty(charset, UTF-8); //提交的数据编码connection.setRequestProperty(Content-type, application/json); //提交的数据格式connection.setRequestProperty(accept, application/json); //接收的数据格式connection.setConnectTimeout(30000); //30秒连接超时connection.setReadTimeout(30000); //30秒读取超时connection.connect();if (param ! null !.equals(param)) {os connection.getOutputStream();osw new OutputStreamWriter(os);bw new BufferedWriter(osw);bw.write(param);bw.flush();}int status connection.getResponseCode();if (status 200) {is connection.getInputStream();rsd new InputStreamReader(is, UTF-8);br new BufferedReader(rsd);String s;while ((s br.readLine()) ! null) {sb.append(s);}} else {return {\ResuleState\:\-1\,\Msg\:\连接异常\};}} catch (MalformedURLException e) {e.printStackTrace();} catch (ProtocolException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {try {if (br ! null) {br.close();}if (rsd ! null) {rsd.close();}if (is ! null) {is.close();}if (bw ! null) {bw.close();}if (osw ! null) {osw.close();}if (os ! null) {os.close();}if (connection ! null) {connection.disconnect();}} catch (IOException e) {e.printStackTrace();}}return sb.toString();}举例 MapString, Object map new HashMap();map.put(currentPage,paramData.getCurrentPage());map.put(pageSize,paramData.getPageSize());map.put(addrList,paramData.getAddrList());map.put(startTime,paramData.getStartTime());map.put(endTime,paramData.getEndTime());String params JSONObject.toJSONString(map);String registerResult HttpUtils.doPost(base url, params);JSONObject result JSONObject.parseObject(registerResult);二、远程调用GET时的方法 方法一 public static String doGet(String url, MapString, Object param) {StringBuffer sb new StringBuffer(url?);IteratorMap.EntryString, Object iterator param.entrySet().iterator();while (iterator.hasNext()) {Map.EntryString, Object entry iterator.next();sb.append(entry.getKey()).append().append(entry.getValue()).append();}sb sb.deleteCharAt(sb.length() - 1);log.info(Http-GET 请求 sb.toString());String data ;// 创建请求对象HttpGet httpGet new HttpGet(sb.toString());// 设置参数HttpParams params new BasicHttpParams();HttpConnectionParams.setConnectionTimeout(params, 10000);HttpConnectionParams.setSoTimeout(params, 10000);// 执行请求的对象HttpClient client new DefaultHttpClient(params);// 执行请求镀锡try {HttpResponse resp client.execute(httpGet);// 判断是否响应成功if (resp.getStatusLine().getStatusCode() 200) {// 获取响应 的数据HttpEntity entity resp.getEntity();data EntityUtils.toString(entity, utf-8);}} catch (ClientProtocolException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return data;}方法二 public static String doGet(String host, String path, String method,String encoding,MapString, String headers,MapString, String querys)throws Exception {String body ; // HttpClient httpClient wrapClient(host);CloseableHttpClient httpClient HttpClients.createDefault();CloseableHttpResponse response null;HttpGet request new HttpGet(buildUrl(host, path, querys));for (Map.EntryString, String e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}response httpClient.execute(request);HttpEntity entity (HttpEntity) response.getEntity();if (entity ! null) {body EntityUtils.toString(entity, encoding);}////json根据key取value// JSONObject jsonObject JSONObject.parseObject(body); // String value jsonObject.getString(bodyData); // JSONObject jsonObject1 JSONObject.parseObject(value); // String list jsonObject1.getString(list);EntityUtils.consume(entity);response.close(); // System.out.println(数据内容 body); // System.out.println(value list);return body;}
http://www.sadfv.cn/news/49853/

相关文章:

  • 网站建设 投标上海一条网络科技有限公司
  • 昆山建设局网站表格下做网站什么框架方便
  • 销售网站模板网站培训机构
  • 怎么建设免费网站域名网页制作论坛
  • 南京城乡住房建设厅网站浙江建设信息港网站
  • 好用的网站建设工具临沂做网站哪家好
  • 云南建设局网站wordpress侧导航菜单
  • 建设网站能赚钱加盟凡科建站
  • 专业网站建设品牌策划方案前端开发岗位职责
  • 做网站的服务器网站建设基本常识
  • 手机网站页面大小网络规划设计师备考
  • 重庆沛宣网站建设长沙网站优化步骤
  • 扬州广陵区建设局网站网站开发品牌
  • 建设局考试通知文件网站百度seo技术优化
  • 怎么建立一个小说网站网站备案负责人 更换
  • 做淘客网站 备案响应式网站常用宽度
  • 闲鱼网站是哪家公司做的页面设计简称
  • 环保主题静态网站模板下载免费学编程的app
  • 做网站用的大图企业做网站的流程
  • 推广网站最有效方法国医堂网站平台建设
  • 小购物网站建设忠益网站建设
  • 合工大智能院网站建设广州企业网站建设电话
  • 做私单的网站网页设计与制作教程ps
  • 湘潭专业网站建设湘潭振企专业电子商务平台开发内容
  • 网站便民服务平台怎么做天津app制作
  • 域名可以做网站名吗网站关键词排名怎么做上去
  • 网站推广的方式有哪些?个人博客搭建
  • 建设银行信用卡网站多少网页浏览器哪个好用
  • 设计素材的网站qq怎么做放资源的网站
  • 凤岗做网站在线文字编辑器