Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java中的URL:为什么字符串在“后”部分+&引用;不被考虑吗?_Java_Url_Inputstream - Fatal编程技术网

Java中的URL:为什么字符串在“后”部分+&引用;不被考虑吗?

Java中的URL:为什么字符串在“后”部分+&引用;不被考虑吗?,java,url,inputstream,Java,Url,Inputstream,我正在使用URL的,更准确地说,是关于堆栈溢出的 网站URL部分的问题结构如下: /questions/tagged/tag+anotherTag+lastTag 当尝试使用URL时,我只得到第一个标记的问题 例子 实际链接是一个链接(从某种意义上说,从来没有任何问题与两个标记一起发布过),正如您所看到的,代码只查找用第一个标记标识的问题 Cobol+Hibernate只是一个很好地解释问题的示例,我知道没有逻辑将这两个标记放在一起。这个curl命令和输出说明了一些问题: $ curl 'h

我正在使用
URL的
,更准确地说,是关于堆栈溢出的

网站
URL
部分的
问题结构如下:

/questions/tagged/tag+anotherTag+lastTag
当尝试使用
URL
时,我只得到第一个标记的问题

例子 实际链接是一个链接(从某种意义上说,从来没有任何问题与两个标记一起发布过),正如您所看到的,代码只查找用第一个标记标识的问题



Cobol+Hibernate
只是一个很好地解释问题的示例,我知道没有逻辑将这两个标记放在一起。

这个
curl
命令和输出说明了一些问题:

$ curl 'http://stackoverflow.com/questions/tagged/cobol+hibernate'
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/questions/tagged/cobol">here</a>.</h2>
</body></html>
看起来您需要一些代表才能同时搜索多个标记。如果我打开
http://stackoverflow.com/questions/tagged/cobol+hibernate
在一个匿名窗口(我没有登录)中,第二个和更多的标签被删除

所以如果你想用Java做这个查询, 看起来您需要以编程方式登录

我想这是因为搜索多个标记可能会对数据库造成负担,因此它的使用仅限于有经验的用户。
您可能会在MSE上得到一个明确的答案。

“实际链接是一个空白页,正如您所看到的,代码只查找第一个标记标识的问题。”有趣的是,“空白页”似乎在为我搜索带有两个标记的问题。@Powerlord为空,因为它不包含任何包含两个标记的问题……这是因为加号充当AND运算符。它正在搜索包含这两个标记的项目。尝试使用java+swing之类的标记,效果很好。它会给您一个空页面,因为没有人用cobol和hibernate作为标记来提问。该页面用UTF-8编码。使用新的InputStreamReader(url.openStream())
将使用您自己机器的默认字符集读取页面的字节。您的默认字符集是UTF-8吗?(如果你在Windows上运行,答案是否定的。)@ChaseHenslee这有点不直观,因为搜索非标记是通过查询字符串完成的用于替换查询字符串中的空格。这正是我想要的答案。用隐姓埋名的方式试过,你完全正确。谢谢你抽出时间。你有任何链接知道如何编程登录吗?我已经有一段时间没有使用它了,但是堆栈交换API应该可以帮助你:非常感谢。将定义。过来看。在这里,有一个接受。
<div class="tags t-cobol">
<div class="tags t-batch-file t-cobol t-mainframe t-vsam">
<div class="tags t-cobol t-mainframe">
<div class="tags t-cobol t-opencobol t-microfocus">
<div class="tags t-cobol">
https://stackoverflow.com/questions/tagged/cobol+hibernate
// Nothing because there is no question under both tags
https://stackoverflow.com/questions/tagged/cobol+hibernate
$ curl 'http://stackoverflow.com/questions/tagged/cobol+hibernate'
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/questions/tagged/cobol">here</a>.</h2>
</body></html>
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Location: /questions/tagged/cobol