feign发送get请求时用复杂类传参

如题,网上都有做法,只有有些人说的不清楚。而我自己也遇到了其他坑这里记录一下

1.就是网上说的做法:

  客户端:application.yml加上配置:

  feign:    httpclient:      enabled: true请求接口上
 @RequestMapping(method = RequestMethod.GET,value = "***",consumes = ("application/json"))
    ResultVo<List<Goods>> selectGoods(Goods goods);

  pom上:    

       <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.6</version>
        </dependency>
        <!--使用Apache HttpClient替换Feign原生httpclient-->
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-httpclient</artifactId>
            <version>10.0.1</version>
        </dependency>

服务端:接口参数上加上 @RequestBody 注解

2.自己遇到的坑:

  一开始不知道为什么,请求还是不行,依旧调用jdk的HttpURLConnection 的 getOutputStream0 方法(想判断feign.httpclient.enalble是否生效,可以在方法里打断点)。之后尝试了其他解决方式,发现报错没有feign.httpclient.ApacheHttpClient类,查找一下果然没有这个类,原来之前pom没有把jar导进来。使用上面的方法,reimport jar包~done!

原文地址:https://www.cnblogs.com/jaxlove-it/p/9724073.html

时间: 2024-08-01 13:58:05

feign发送get请求时用复杂类传参的相关文章

Feign发送Get请求时,采用POJO对象传递参数的最终解决方案 Request method &#39;POST&#39; not supported (附带其余好几个坑)

yml: feign: httpclient: enabled: true properties: #feign feign.httpclient.enabled=true <!-- https://mvnrepository.com/artifact/io.github.openfeign/feign-httpclient --> <dependency> <groupId>io.github.openfeign</groupId> <artifac

Nodejs发送Post请求时出现socket hang up错误的解决办法

参考nodejs官网发送http post请求的方法,实现了一个模拟post提交的功能.实际使用时报socket hang up错误. 后来发现是请求头设置的问题,发送选项中需要加上headers字段信息(这个估计也和对方的服务器有关,对于不完成的post请求头,可能被丢弃了). 完整的代码如下(遇到类型问题的同学可以做个参考): var querystring = require('querystring') , http = require('http'); var data = query

IE内核发送ajax请求时不会将url中的参数编码

有一次用户遇到创建文件,名称为中文时乱码的问题. 经调查,发现用户使用的是国产浏览器ie模式 抓取请求发现 IE: 键 值请求 POST /Handlers/CreateTxtFile.ashx?filename=阿斯达是.txt HTTP/1.1Accept */*Content-Type application/x-www-form-urlencoded; charset=UTF-8X-Requested-With XMLHttpRequestReferer http://mt.sogou.

httpclient发送request请求时设置header和timeout

package com.xxx.xxx.common; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Map; import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.Htt

关于在php中使用curl发送get请求时参数传递问题的解析

get请求是最简单的请求,不过要注意自己的请求是http请求还是https的请求,因为https请求时要关闭SSL验证,不然验证通不过,没有办法请求到数据. GET请求的参数 get传递参数和正常请求url传递参数的方式一样 1 function get_info($card){ 2 $url ="http://www.sdt.com/api/White/CardInfo?cardNo=".$bank_card; 3 $ch = curl_init(); 4 //设置选项,包括URL

JQuery发送ajax请求时中文乱码

先排除项目故障: 1.web.xml中是否配置了字符拦截器 <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name

前端form标签发送post请求,服务器用Java类继承HttpServlet,并返回数据

1.form表单提交: <form action="http://localhost:8080/test/Login" method="post"> 用户:<input type="text" name="username"/><br/> 密码:<input type="password" name="password"/><br/&

发送网络请求时,字符串按字符顺序拼接,之后用MD5加密,去后8位

+(NSString *)jsonTokenString:(NSDictionary *)dic { myDic = [NSMutableDictionary dictionary]; for (NSString *key in dic) { //判断类型 if ([dic[key] isKindOfClass:[NSDictionary class]]) { NSError *error = nil; NSData *data = [NSJSONSerialization dataWithJS

使用httpclient实现http链接池与使用HttpURLConnection发送http请求的方法与性能对比

使用httpclient实现http链接池与使用HttpURLConnection发送http请求的方法与性能对比 在项目中需要使用http调用接口,实现了两套发送http请求的方法,一个是使用apache的httpclient提供的http链接池来发送http请求,另一个是使用java原生的HttpURLConnection来发送http请求,并对两者性能进行了对比. 使用httpclient中的链接池发送http请求 使用最新的4.5.2版httpclient进行实现.在maven中引入 <