HttpClient的HTTPGET不接受方括号 [英] httpclient httpget doesn't accept square brackets

查看:1198
本文介绍了HttpClient的HTTPGET不接受方括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用HTTPGET正在返回一个文件,HTTPGET不允许参数是一个URL,它必须是一个URL,但是,我所面临的问题是,我有*使用HttpClient的,我需要要能够把特殊字符在URI / URL例如方括号这样:

I'm using HttpGet to return a file, and HttpGet doesn't allow the argument to be a URL, it has to be a URL, however the problem I face is that I have* to use httpclient, and I need to be able to put special characters in the URI/URL e.g. square brackets so:

http://127.0.0.1:8080/exists/rest/db/catalog?_query=//album[contains(title,"")]

我该怎么办?

推荐答案

<一个href=\"http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLEn$c$cr.html#en$c$c%28java.lang.String,%20java.lang.String%29\"相对=nofollow> URLEn code 传递给HTTPGET与 URLEn coder.en code(yourQueryString之前包含特殊字符的URL的一部分, UTF-8);

URLEncode the portion of the url containing the special chars before passing to HttpGet with URLEncoder.encode(yourQueryString,"UTF-8");

这篇关于HttpClient的HTTPGET不接受方括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆