亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

[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條經驗 獲得超7個贊

注解中屬性代表該請求返回參數類型為json格式;
下面代碼無非就是設置http請求header中的contentType格式,和設置請求體內容

查看完整回答
反對 回復 2018-11-03
  • 2 回答
  • 0 關注
  • 862 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號