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

做淘宝客网站需要什么资质网站建设的参考文献英文

做淘宝客网站需要什么资质,网站建设的参考文献英文,给一个网站,茂名住房证书城乡建设局官方网站在Java中#xff0c;有多种方式可以实现HTTP或HTTPS请求。以下是使用第三方库Apache HttpClient来实现HTTP/HTTPS请求的工具类。 优势和特点 URIBuilder的优势在于它提供了一种简单而灵活的方式来构造URI#xff0c;帮助开发人员避免手动拼接URI字符串#xff0c;并处理参…在Java中有多种方式可以实现HTTP或HTTPS请求。以下是使用第三方库Apache HttpClient来实现HTTP/HTTPS请求的工具类。 优势和特点 URIBuilder的优势在于它提供了一种简单而灵活的方式来构造URI帮助开发人员避免手动拼接URI字符串并处理参数的编码和转义。此外URIBuilder还提供了其他一些有用的方法例如添加路径段、设置查询字符串等。这使得URI的构建过程更加清晰和易于管理。 使用 Apache HttpClient 要使用Apache HttpClient你首先需要将HttpClient库添加到你的项目中。如果你使用Maven可以在pom.xml中添加以下依赖 dependency      groupIdorg.apache.httpcomponents/groupId      artifactIdhttpclient/artifactId      version4.5.13/version !-- 使用时请检查最新版本 --  /dependency 然后你可以使用以下代码示例来发送HTTP请求 import org.apache.commons.collections.MapUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.HashMap; import java.util.Map; public class HttpsUtils {     private static Logger logger LoggerFactory.getLogger(HttpsUtils.class);     static CloseableHttpClient httpClient;     static CloseableHttpResponse httpResponse;     public static CloseableHttpClient createSSLClientDefault() {         try {             SSLContext sslContext new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {                 // 信任所有                 public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {                     return true;                 }             }).build();             HostnameVerifier hostnameVerifier NoopHostnameVerifier.INSTANCE;             SSLConnectionSocketFactory sslsf new SSLConnectionSocketFactory(sslContext, hostnameVerifier);             return HttpClients.custom().setSSLSocketFactory(sslsf).build();         } catch (KeyManagementException e) {             e.printStackTrace();         } catch (NoSuchAlgorithmException e) {             e.printStackTrace();         } catch (KeyStoreException e) {             e.printStackTrace();         }         return HttpClients.createDefault();     }     /**     * 发送https||http get请求     *     * throws Exception     */     public static String sendByHttpGet(MapString, Object params, String url) {         try {             URIBuilder uriBuilder new URIBuilder(url);             if(MapUtils.isNotEmpty(params)) {                 for (Map.EntryString, Object entry : params.entrySet()) {                     uriBuilder.setParameter(entry.getKey(), entry.getValue().toString());                 }             }             HttpGet httpGet new HttpGet(uriBuilder.build());             httpGet.addHeader(Content-type, application/json; charsetutf-8);             httpGet.setHeader(Accept, application/json);             httpClient HttpsUtils.createSSLClientDefault();             httpResponse httpClient.execute(httpGet);             HttpEntity httpEntity httpResponse.getEntity();             if (httpEntity ! null) {                 String jsObject EntityUtils.toString(httpEntity, UTF-8);                 return jsObject;             } else {                 return null;             }         } catch (Exception e) {             e.printStackTrace();             logger.error(description : {{}} ,details : {{}}, 请求异常, e.getStackTrace());         } finally {             try {                 httpResponse.close();                 httpClient.close();             } catch (IOException e) {                 logger.error(description : {{}} ,details : {{}}, 请求流关闭异常, e.getStackTrace());                 e.printStackTrace();             }         }         return null;     }     /**     * 发送https||http get请求     *     * throws Exception     */     public static byte[] sendByteByHttpGet(MapString, Object params, String url) {         try {             URIBuilder uriBuilder new URIBuilder(url);             if(MapUtils.isNotEmpty(params)) {                 for (Map.EntryString, Object entry : params.entrySet()) {                     uriBuilder.setParameter(entry.getKey(), entry.getValue().toString());                 }             }             HttpGet httpGet new HttpGet(uriBuilder.build());             httpGet.addHeader(Content-type, application/json; charsetutf-8);             httpGet.setHeader(Accept, application/json);             httpClient HttpsUtils.createSSLClientDefault();             httpResponse httpClient.execute(httpGet);             HttpEntity httpEntity httpResponse.getEntity();             if (httpEntity ! null) {                 byte[] bytes EntityUtils.toByteArray(httpEntity);                 return bytes;             } else {                 return new byte[0];             }         } catch (Exception e) {             e.printStackTrace();             logger.error(description : {{}} ,details : {{}}, 读取二进制保存的图片异常, e.getStackTrace());         } finally {             try {                 httpResponse.close();                 httpClient.close();             } catch (IOException e) {                 e.printStackTrace();                 logger.error(description : {{}} ,details : {{}}, 读取二进制保存的图片关闭流时异常, e.getStackTrace());             }         }         return new byte[0];     } }
http://www.hkea.cn/news/14590668/

相关文章:

  • 北京专业网站设计制作黑河做网站的公司
  • 网站底部美化代码社区主题wordpress
  • 医疗机构网站长沙岳麓区
  • 六安网站建设六安网站开发属于什么费用
  • 紫网站建设哪个网站域名便宜
  • 中专网站建设与数据管理是什么做服装店网站的素材
  • 网站做权重的方法自己做的网站360显示过期
  • wordpress个人站无法升级企业网站公告怎么做
  • ai特效字体网站怎么在家开网店挣钱呢
  • 网站策划界面效果感受心得成都seo达人
  • 网站建设奖项做外贸要自己建网站吗
  • 如何用云服务器搭建个人网站镇江发布的最新消息
  • 房地产市场信息系统网站手工做皮具国外的网站
  • 做行业门户网站要投资多少钱设计师论坛
  • 淄川区建设局网站自己建设论坛网站
  • 室内设计网站免费模板网站建设要多少钱怎样
  • 网站广告推广公司开发网站的工具有哪些
  • 网站的备案信息pc网站怎么做适配
  • 门户定制网站建设公司公司logo注册商标流程 费用
  • 帮忙做网站的协议建查查官网
  • 怎么做frontpage网站word网站链接怎么做
  • 90设计网站如何接单百度软件中心下载
  • 东莞seo建站排名北京知名seo公司精准互联
  • 网站整体建设方案设计软件发展的四个阶段
  • 唐山模板建站系统广告营销行业
  • 大石桥做网站wordpress内存占用大
  • 枣阳做网站大连企业名录大全
  • 邯郸网站设计价格和什么人合作做游戏视频网站
  • 网站后台功能开发seo是怎么优化推广的
  • 网站开发要懂英文吗科技制作网站