当前位置: 首页>后端>正文

springboot java调用flask python写的

服务a用html" class="superseo">flask,服务b用的springboot,服务a写的接口,用python很容易就调通了,java来调,坑有点多

1、url最后的斜杠必须两边对应上,否则flask会先308,而且 content type [text/html;charset=utf-8],连对应的HttpMessageConverter都没有

org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [com.api.ApiResponse<java.lang.String>] and content type [text/html;charset=utf-8]

2、get请求的参数传递,

两种方式,一是uri参数

如/api/v1/test/{code}} restTemplate.exchange(URL, HttpMethod.GET, new HttpEntity<Dto>(), new ParameterizedTypeReference<ApiResponse<List<String>>>() { }, code);

另一种,接在uri上,如如/api/v1/test/?code=358

restTemplate.exchange(URL, HttpMethod.GET, new HttpEntity<Object>(), new ParameterizedTypeReference<ApiResponse<List<String>>>() { });

 

springboot java调用flask python写的,第1张


https://www.xamrdz.com/backend/3j21923993.html

相关文章: