为了账号安全,请及时绑定邮箱和手机立即绑定

[Java]请问springMVC这段代码啥意思,关于httpclient的

[Java]请问springMVC这段代码啥意思,关于httpclient的

慕沐林林 2018-10-28 14:14:51
这是一个controller方法的尾巴,方法上的返回值是void请问这个注解中的属性和下面那段代码表示的什么意思“JsonParam”和“cfg.getJsonParam()”表示的是项目里的一个属性类,不用在意 @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)   public void upload(。。。。。。。。 HttpHeaders headers = new HttpHeaders();       MediaType mediaType = new MediaType("application", "merge-patch+json");       headers.setContentType(mediaType);       HttpEntity<JsonParam> entity = new HttpEntity<>(cfg.getJsonParam(), headers);       HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();       RestTemplate restTemplate = new RestTemplate(requestFactory);为了看的方便我把包放出来import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate;
查看完整描述

2 回答

?
qq_花开花谢_0

TA贡献1835条经验 获得超6个赞

注解中属性代表该请求返回参数类型为json格式;
下面代码无非就是设置http请求header中的contentType格式,和设置请求体内容

查看完整回答
反对 回复 2018-11-03
  • 2 回答
  • 0 关注
  • 773 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信