bug记录:httpclient-invalid query

背景

前几天做一个任务要调用别的系统的接口。系统严格要求我的请求url是utf-8编码格式的。但是我真正调用人家接口进行post请求的时候,却报错,invalid query。

过程

各种查资料以后,资料都说是请求的参数里面有编码问题。但是我自己粘出来再直接请求是能获得正常的返回值的。于是我看到了很多人强制将参数给改成utf-8的编码,在一个帖子里用了URLEncoder.enode():

String searchdqcph = "粤s.F3462";
String searchcx = "G";
String url = "http://www.dgsfs.net/product_search.asp?searchdqcph="+URLEncoder.encode(searchdqcph, 'utf-8')+"&searchcx="+searchcx;
String htmlContent = GetHttpClint.doGet(url);

我这么写以后还是报错,就彻底没办法了。

解决

后来问同事,同事让我把请求的最终url直接粘出来贴到浏览器地址栏,请求以后又从地址栏里粘出来。才发现原来是有一个等号写成了别的编码的等号,在那个等号的地方变成了一串乱码,在eclipse里面看不太出来,但是请求的时候确报错。
这一招好好用啊,记住了~

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提示错误[ERROR] [ERROR] Some problems were encountered while processing the POMs: [ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-webdav-jackrabbit:1.0-beta-6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: commons-httpclient:commons-httpclient:jar:3.1 (absent): Could not transfer artifact commons-httpclient:commons-httpclient:jar:3.1 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: connect timed out @ @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project org.drools:droolsjbpm-integration:7.74.0-SNAPSHOT (D:\droolsjbpm-integration-main\droolsjbpm-integration-main\pom.xml) has 1 error [ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-webdav-jackrabbit:1.0-beta-6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: commons-httpclient:commons-httpclient:jar:3.1 (absent): Could not transfer artifact commons-httpclient:commons-httpclient:jar:3.1 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: connect timed out -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值