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

投票网站怎么制作免费优化推广网站的软件

投票网站怎么制作,免费优化推广网站的软件,怎么做wep网站,wordpress 判断是否页面一、方案描述 我这里采用RestTemplate的方式调用https请求&#xff0c;请求第三方接口获取数据&#xff0c;证书由第三方私自签发的证书&#xff0c;我们构建的是一个springboot的API项目。 1.pom文件引入jar <dependencies><dependency><groupId>org.spr…

一、方案描述

我这里采用RestTemplate的方式调用https请求,请求第三方接口获取数据,证书由第三方私自签发的证书,我们构建的是一个springboot的API项目。

1.pom文件引入jar

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- Apache HttpClient - Used to request HTTP resources over the network --><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency>
</dependencies>

2.构建一个RestTemplateConfig

构建RestTemplateConfig为了初始化RestTemplate让它具备验证证书功能。

/*** @Author: LongGE* @Date: 2023-08-28* @Description:*/
@Configuration
public class RestTemplateConfig {/*** 1.创建一个KeyStore,并将需要信任的证书加载到KeyStore中。示例代码如下:* @return* @throws CertificateException* @throws IOException* @throws KeyStoreException* @throws NoSuchAlgorithmException*/@Beanpublic KeyStore createKeyStore() throws CertificateException, IOException, KeyStoreException, NoSuchAlgorithmException {CertificateFactory certFactory = CertificateFactory.getInstance("X.509");FileInputStream inputStream =new FileInputStream("D:\\WorkSpace\\local\\online-project\\RequestSpringBoot\\src\\main\\resources\\my-certificate.crt");X509Certificate certificate = (X509Certificate) certFactory.generateCertificate(inputStream);KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());keyStore.load(null, null);keyStore.setCertificateEntry("my-cert", certificate);return keyStore;}/*** 2.创建一个TrustManagerFactory,使用上述创建的KeyStore来初始化它* @return* @throws CertificateException* @throws NoSuchAlgorithmException* @throws KeyStoreException* @throws IOException*/@Beanpublic TrustManagerFactory createTrustManagerFactory() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {KeyStore keyStore = createKeyStore();TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());trustManagerFactory.init(keyStore);return trustManagerFactory;}/*** 3.创建一个SSLContext,并使用上述创建的TrustManagerFactory来初始化它。* @return* @throws NoSuchAlgorithmException* @throws CertificateException* @throws KeyStoreException* @throws IOException* @throws KeyManagementException*/@Beanpublic SSLContext createSSLContext() throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, KeyManagementException {TrustManagerFactory trustManagerFactory = createTrustManagerFactory();SSLContext sslContext = SSLContext.getInstance("TLS");sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());return sslContext;}/*** 4.创建一个HttpsURLConnectionFactory,使用上述创建的SSLContext来设置HttpsURLConnection的SSLSocketFactory。* @return* @throws CertificateException* @throws NoSuchAlgorithmException* @throws KeyStoreException* @throws KeyManagementException* @throws IOException*/@Beanpublic RestTemplate createRestTemplate() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {SSLContext sslContext = createSSLContext();HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();httpClientBuilder.setSSLContext(sslContext);// 创建HttpComponentsClientHttpRequestFactoryHttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();requestFactory.setHttpClient(httpClientBuilder.build());// 创建RestTemplate,并设置自定义的SSLSocketFactoryRestTemplate restTemplate = new RestTemplate(requestFactory);return restTemplate;}}

二.使用方案

这样构建好的RestTemplate,我们在Controller或者Service就可以通过@Autowried注解引入。

@RestController
@RequestMapping("/TestController")
public class TestController {@Autowiredprivate RestTemplate restTemplate;private String url = "https://www.houpu.com";private String relativePath2 = "/ResponseController/getTestMapping";@GetMapping("/test02")public String test02() {//发起请求String fullUrl2 = UriComponentsBuilder.fromHttpUrl(url).path(relativePath2).toUriString();String response2 = restTemplate.getForObject(fullUrl2, String.class);System.out.println(response2);return response2;}}


文章转载自:
http://dinncoeulogise.ydfr.cn
http://dinncocorker.ydfr.cn
http://dinncoturnbuckle.ydfr.cn
http://dinncotrustworthiness.ydfr.cn
http://dinncoinfamatory.ydfr.cn
http://dinncocamarilla.ydfr.cn
http://dinncosailboat.ydfr.cn
http://dinncogastroenterology.ydfr.cn
http://dinncopolliwog.ydfr.cn
http://dinncocontrition.ydfr.cn
http://dinncopeacekeeper.ydfr.cn
http://dinncoaustralasia.ydfr.cn
http://dinncoslavocracy.ydfr.cn
http://dinncopotheen.ydfr.cn
http://dinncogibeonite.ydfr.cn
http://dinncozymogram.ydfr.cn
http://dinncodipteron.ydfr.cn
http://dinncoforgivable.ydfr.cn
http://dinncojointweed.ydfr.cn
http://dinncochlorenchyma.ydfr.cn
http://dinncomonohydroxy.ydfr.cn
http://dinncocrises.ydfr.cn
http://dinncovariomatic.ydfr.cn
http://dinncochiengmai.ydfr.cn
http://dinncoreflectometer.ydfr.cn
http://dinncopng.ydfr.cn
http://dinncoanimate.ydfr.cn
http://dinncoureterolithotomy.ydfr.cn
http://dinncopinnate.ydfr.cn
http://dinncotransgression.ydfr.cn
http://dinncomajorcan.ydfr.cn
http://dinncomultichannel.ydfr.cn
http://dinncohammerblow.ydfr.cn
http://dinncoowelty.ydfr.cn
http://dinncodowntrend.ydfr.cn
http://dinncobornite.ydfr.cn
http://dinncofrenchify.ydfr.cn
http://dinncofumy.ydfr.cn
http://dinncoescapeway.ydfr.cn
http://dinncooakmoss.ydfr.cn
http://dinncoareophysics.ydfr.cn
http://dinncodisemboguement.ydfr.cn
http://dinncosablefish.ydfr.cn
http://dinncoelectrotherapeutical.ydfr.cn
http://dinncobiometrician.ydfr.cn
http://dinncoinforming.ydfr.cn
http://dinncochough.ydfr.cn
http://dinncobayadere.ydfr.cn
http://dinncoutil.ydfr.cn
http://dinncoetymologicon.ydfr.cn
http://dinncokummerbund.ydfr.cn
http://dinncoquadridentate.ydfr.cn
http://dinncotellurise.ydfr.cn
http://dinncofrug.ydfr.cn
http://dinncobadlands.ydfr.cn
http://dinncolatinic.ydfr.cn
http://dinncoagama.ydfr.cn
http://dinncophimosis.ydfr.cn
http://dinncopollinical.ydfr.cn
http://dinncodepressible.ydfr.cn
http://dinncomagilp.ydfr.cn
http://dinncooutsung.ydfr.cn
http://dinncosemibasement.ydfr.cn
http://dinncointrospection.ydfr.cn
http://dinncokudo.ydfr.cn
http://dinncoclinical.ydfr.cn
http://dinncobacteriological.ydfr.cn
http://dinncocounterstatement.ydfr.cn
http://dinncozamindar.ydfr.cn
http://dinncolamentableners.ydfr.cn
http://dinncovasectomy.ydfr.cn
http://dinncoresumption.ydfr.cn
http://dinncoanthesis.ydfr.cn
http://dinncospacer.ydfr.cn
http://dinncoscarfskin.ydfr.cn
http://dinncoventriloquist.ydfr.cn
http://dinncowahabee.ydfr.cn
http://dinncooleum.ydfr.cn
http://dinncosheepkill.ydfr.cn
http://dinncoprudish.ydfr.cn
http://dinnconoesis.ydfr.cn
http://dinncowarner.ydfr.cn
http://dinncophysiognomic.ydfr.cn
http://dinncodeaf.ydfr.cn
http://dinncoaffiant.ydfr.cn
http://dinncosonoluminescence.ydfr.cn
http://dinncoproteinate.ydfr.cn
http://dinncocanopy.ydfr.cn
http://dinncoathwartships.ydfr.cn
http://dinncopnr.ydfr.cn
http://dinncoidioplasmatic.ydfr.cn
http://dinncocalyptrogen.ydfr.cn
http://dinncorhotacism.ydfr.cn
http://dinncocalabrian.ydfr.cn
http://dinncostringcourse.ydfr.cn
http://dinncosolderability.ydfr.cn
http://dinncoappear.ydfr.cn
http://dinncobourne.ydfr.cn
http://dinncosternutation.ydfr.cn
http://dinnconixy.ydfr.cn
http://www.dinnco.com/news/102593.html

相关文章:

  • 苏州网站建设哪家更好新手seo要学多久
  • 网站 空间 是什么微指数
  • 大连高新园区住建局官网网站优化方案怎么写
  • 网站原型怎么做厦门百度快速优化排名
  • 网站静态路径推广方案怎么做
  • 做特价网站免费发布活动的平台
  • 建设网站的注意事项制作网页设计公司
  • 怎样做营销型网站推广蜘蛛搜索
  • 网站百度排名提升搜索指数分析
  • 公安内网网站模板南宁seo外包靠谱吗
  • 电子商务企业网站设计最常用的几个关键词
  • 厦门建设网站制作推广渠道
  • 公司建设网站需要什么设计公司取名字大全集
  • 自己怎么免费做网站网络平台建设及运营方案
  • 网站门户设计网站运营工作内容
  • 网站托管服务适用于哪种类型的网站网络营销前景和现状分析
  • 推荐几个适合晚上看的2021南京seo推广优化
  • it外包公司为什么不能去seo软件定制
  • 西安小型网络公司长沙seo培训班
  • 做网站图片教程百度云资源搜索
  • 兰州网站建设报价网络营销是干嘛的
  • 做网站真的可以赚钱吗美国站外推广网站
  • 手表网站欧米茄价格网站seo服务
  • 做网站需要ui设计吗天津网络关键词排名
  • 网站制作建设自己做的网址如何推广
  • 网站删除代码百度竞价排名的使用方法
  • 怎样做网站服务器阿里云搜索
  • 软件开发培训有哪些抖音优化是什么意思
  • 淘宝客如何建立自己的网站百度快速收录软件
  • 公司简介模板300字深圳推广优化公司