专业的JAVA编程教程与资源

网站首页 > java教程 正文

springboot java调用flask python写的

temp10 2024-09-22 10:09:14 java教程 8 ℃ 0 评论

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

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

springboot java调用flask python写的

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(), new ParameterizedTypeReference<ApiResponse<List>>() { }, code);

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

restTemplate.exchange(URL, HttpMethod.GET, new HttpEntity

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表