【问题标题】:malformed Java Net URL格式错误的 Java 网络 URL
【发布时间】:2012-02-13 23:08:08
【问题描述】:

我正在制作这样的网址

url = new URL("http","localhost",9080,"/path/to/my/resource/myAction.action");

而不是制作网址:

http://localhost:9080/path/to/my/resource/myAction.action

它发出请求:

http://www.localhost.com/path/to/my/resource/myAction.action

【问题讨论】:

  • 你确定吗?尝试打印 url 的内容,因为当我尝试打印 url 的内容时,它是 http://localhost:9080/path/to/my/resource/myAction.action
  • 试过了,给我打印错误的网址..

标签: java http url


【解决方案1】:

试试这个:

url = new URL("http://localhost:9080/path/to/my/resource/myAction.action");

【讨论】:

  • 如果你想保留你正在使用的版本,我认为如果你使用127.0.0.1而不是localhost会工作
  • 我实际上在输入 URL 时出错了,在测试这个时我在 http: 之后省略了 // 所以调用 http:localhost:9080/path/to/my/resource /myAction.action,我一输入 // 它就恢复为 www.localhost.com URL :S
  • 你试过用 127.0.0.1 代替吗?
猜你喜欢
  • 2014-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-22
  • 2020-05-13
  • 2017-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多