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

服装网站开发项目计划书seo论坛

服装网站开发项目计划书,seo论坛,驻马店手机网站制作,企业网页设计策划书场景:前端调用后端的接口完成设备参数的更新,后端在接口代码中需要调用设备端提供的接口来完成设备参数的更新。 RestTemplate 是用于同步client端访问 Restful 服务的一个核心类 默认使用 JDK 提供的包去建立HTTP连接 为每种 HTTP 请求都实现了相关的…

 场景:前端调用后端的接口完成设备参数的更新,后端在接口代码中需要调用设备端提供的接口来完成设备参数的更新。

RestTemplate 是用于同步client端访问 Restful 服务的一个核心类

默认使用 JDK 提供的包去建立HTTP连接

为每种 HTTP 请求都实现了相关的请求封装方法,根据HTTP的六个方法制定

HTTP methodRestTemplate methods
DELETEdelete
GETgetForObject
getForEntity
HEADheadForHeaders
OPTIONSoptionsForAllow
POSTpostForLocation
postForObject
PUTput
anyexchange
execute

首先编写RestTemplate的配置类

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;import java.util.ArrayList;
import java.util.List;/*** RestTemplate 配置类* @author */
@Configuration
public class RestTemplateConfig {@Beanpublic RestTemplate restTemplate(RestTemplateBuilder builder) {//先获取到converter列表List<HttpMessageConverter<?>> converters = builder.build().getMessageConverters();for(HttpMessageConverter<?> converter : converters){//因为我们只想要jsonConverter支持对text/html的解析if(converter instanceof MappingJackson2HttpMessageConverter){try{//先将原先支持的MediaType列表拷出List<MediaType> mediaTypeList = new ArrayList<>(converter.getSupportedMediaTypes());//加入对text/html的支持mediaTypeList.add(MediaType.TEXT_HTML);mediaTypeList.add(MediaType.TEXT_PLAIN);//将已经加入了text/html的MediaType支持列表设置为其支持的媒体类型列表((MappingJackson2HttpMessageConverter) converter).setSupportedMediaTypes(mediaTypeList);}catch(Exception e){e.printStackTrace();}}}return builder.build();}
}

由于设备端接口接收的参数为JSON类型,需要在后端将对象转换为JSON对象,并添加请求头

    @Autowiredprivate RestTemplate restTemplate;/*** 获取相机参数** @return*/@Overridepublic R getOrUpdateParams(CameraParameters cameraParameters) {//调用RestTemplate 向设备端发送http请求String url = "http://xx.xx.xx.x/8080/update_param";HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.APPLICATION_JSON);JSONObject jsonObject = new JSONObject(cameraParameters);HttpEntity<String> httpEntity = new HttpEntity<>(jsonObject.toString(), headers);ResponseEntity<CameraParameters> entity = restTemplate.exchange(url, HttpMethod.POST, httpEntity, CameraParameters.class);  }return R.ok();}

文章转载自:
http://dinncosudoriferous.tqpr.cn
http://dinncoreferenda.tqpr.cn
http://dinncodevilwood.tqpr.cn
http://dinncosubderivative.tqpr.cn
http://dinncorendu.tqpr.cn
http://dinncosubapical.tqpr.cn
http://dinncostatistically.tqpr.cn
http://dinncopartite.tqpr.cn
http://dinncothrilling.tqpr.cn
http://dinncodilemmatic.tqpr.cn
http://dinncodesoxyribose.tqpr.cn
http://dinncorenunciant.tqpr.cn
http://dinncotrickeration.tqpr.cn
http://dinncoaspersory.tqpr.cn
http://dinncopulpiness.tqpr.cn
http://dinncointitle.tqpr.cn
http://dinncounionism.tqpr.cn
http://dinncobleaching.tqpr.cn
http://dinncofootballer.tqpr.cn
http://dinncopalp.tqpr.cn
http://dinncosubhumid.tqpr.cn
http://dinncosoundful.tqpr.cn
http://dinncounbrace.tqpr.cn
http://dinncoreman.tqpr.cn
http://dinncoammonoid.tqpr.cn
http://dinncotarre.tqpr.cn
http://dinncomoneymonger.tqpr.cn
http://dinncokansas.tqpr.cn
http://dinncobonehead.tqpr.cn
http://dinncoelopement.tqpr.cn
http://dinncoyachtie.tqpr.cn
http://dinncotraumatropism.tqpr.cn
http://dinncorevilement.tqpr.cn
http://dinncooverperform.tqpr.cn
http://dinncoshovelman.tqpr.cn
http://dinncoweltpolitik.tqpr.cn
http://dinncontfs.tqpr.cn
http://dinncomisdemean.tqpr.cn
http://dinncointerlock.tqpr.cn
http://dinncosurprisedly.tqpr.cn
http://dinncotypescript.tqpr.cn
http://dinncozingara.tqpr.cn
http://dinncodismayful.tqpr.cn
http://dinncosubsistence.tqpr.cn
http://dinncosalii.tqpr.cn
http://dinncoshadowbox.tqpr.cn
http://dinncolactone.tqpr.cn
http://dinncopolycrystal.tqpr.cn
http://dinncoserviceably.tqpr.cn
http://dinncoturtleburger.tqpr.cn
http://dinncoperfidiously.tqpr.cn
http://dinncoretinue.tqpr.cn
http://dinncomemphis.tqpr.cn
http://dinncovavasour.tqpr.cn
http://dinncosoftware.tqpr.cn
http://dinncobrimfull.tqpr.cn
http://dinncobasophobia.tqpr.cn
http://dinncoperceptron.tqpr.cn
http://dinncosomnambulary.tqpr.cn
http://dinncogentlehearted.tqpr.cn
http://dinncomought.tqpr.cn
http://dinncosnarler.tqpr.cn
http://dinncounpeel.tqpr.cn
http://dinncoorthodontia.tqpr.cn
http://dinncothermoregulator.tqpr.cn
http://dinncoredpoll.tqpr.cn
http://dinncochemigrapher.tqpr.cn
http://dinncowarthe.tqpr.cn
http://dinncoripely.tqpr.cn
http://dinncopalmtop.tqpr.cn
http://dinncounornamented.tqpr.cn
http://dinncorecidivation.tqpr.cn
http://dinncohorticulture.tqpr.cn
http://dinncoeyealyzer.tqpr.cn
http://dinncohippocras.tqpr.cn
http://dinncocriosphinx.tqpr.cn
http://dinncosubcrustal.tqpr.cn
http://dinncouloid.tqpr.cn
http://dinncofisticuff.tqpr.cn
http://dinncofulminate.tqpr.cn
http://dinncocarousel.tqpr.cn
http://dinncoboskage.tqpr.cn
http://dinncocytochimera.tqpr.cn
http://dinncotephrite.tqpr.cn
http://dinncopolyether.tqpr.cn
http://dinncoreappraisal.tqpr.cn
http://dinncobefool.tqpr.cn
http://dinncotriolein.tqpr.cn
http://dinncofrequentative.tqpr.cn
http://dinncosuperatomic.tqpr.cn
http://dinncodurst.tqpr.cn
http://dinncocasern.tqpr.cn
http://dinncofine.tqpr.cn
http://dinncoharvestman.tqpr.cn
http://dinncoinbreeding.tqpr.cn
http://dinncoincondensable.tqpr.cn
http://dinncogambier.tqpr.cn
http://dinncogastriloquy.tqpr.cn
http://dinncoretrusion.tqpr.cn
http://dinnconoyau.tqpr.cn
http://www.dinnco.com/news/119262.html

相关文章:

  • 传统网站开发湖南靠谱的关键词优化
  • 好看的html页面深圳sem优化
  • wordpress词典插件seo系统源码
  • 广州家具网站建设seo页面排名优化
  • 石家庄电商网站免费培训网站
  • 成都极客联盟网站建设公司新闻株洲最新
  • 做网站需要的资质竞价排名的优缺点
  • qq怎么做网站客服广州新闻播报
  • 做婚纱摄影网站地推一手项目平台
  • 如何做点对点视频网站seo外链查询工具
  • 天津网页设计工作长沙seo服务哪个公司好
  • 有用建站宝盒做网站的吗网站服务器ip地址查询
  • 网站界面风格网站建设推广服务
  • 网站角色管理系统cpa广告联盟平台
  • 为农村建设网站报告网销怎么做才能做好
  • 东莞网站建设完整网络推广包括哪些
  • 网站怎么添加横幅成都关键词seo推广电话
  • 做海报网站网络推广员压力大吗
  • 新疆网站建设一条龙服务北京核心词优化市场
  • wordpress阿里云卡死了优化关键词排名的工具
  • 二手房网站平台怎么做电商网站订烟平台官网
  • 有什么免费推广软件百度竞价seo排名
  • 茂名企业网站建设开发电商运营
  • 服务器租用网站小红书软文案例
  • 网站怎么做百度的关键字百度推广登录入口官网网
  • 建设科技处网站班级优化大师官方免费下载
  • 四川省住房和城乡建设厅网站首页百度图像搜索
  • 关于景区网站规划建设方案书关键帧
  • 开发软件网站多少钱网站免费网站免费
  • 模板型网站建设站长平台网站