欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

java模拟http请求的错误问题整理

程序员文章站 2023-12-19 14:27:22
在java模拟http请求的时候,报错,代码,错误详情如下: configuration.xml

在java模拟http请求的时候,报错,代码,错误详情如下:

configuration.xml

<?xml version="1.0" encoding="utf-8"?>
<system>
  <!--请求url-->
  <category name="url" description="指标 url相关配置">
    <item name="volumenormurl" value="10.150.33.154:8080/getinfo/getuser" description="临时的url地址"></item>
  </category>
</system>

java code

 string url = configuration.getstring("url.volumenormurl");
    try {
      log.info("=============={}",url);
      string responsestring = httputil.doget(url);
      log.info("crmloginurl responsestring {} {}", url, responsestring);
      return jsonresponse.success();
    } catch (wxexception e) {
      log.error("crmlogin fail... {}, e = {} ", e.getmessage(), e);
      e.printstacktrace();
      return jsonresponse.failure("fail");
    }

错误代码:

java.lang.illegalargumentexception: illegal character in scheme name at index 0: 10.150.33.154:8080/getinfo/getuser
	at java.net.uri.create(uri.java:852)
	at org.apache.http.client.methods.httpget.<init>(httpget.java:69)
	at com.foundersc.ifc.service.base.http.httputil.doget(httputil.java:30)
	at com.foundersc.ifc.volumenorm.controller.test.getnorm(test.java:29)
	at sun.reflect.nativemethodaccessorimpl.invoke0(native method)
	at sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)
	at sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)
	at java.lang.reflect.method.invoke(method.java:498)
	at org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:215)
	at org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:132)
	at org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:104)
	at org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlemethod(requestmappinghandleradapter.java:781)
	at org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:721)
	at org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:83)
	at org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:943)
	at org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:877)
	at org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966)
	at org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:857)
	at javax.servlet.http.httpservlet.service(httpservlet.java:707)
	at org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842)
	at javax.servlet.http.httpservlet.service(httpservlet.java:820)
	at org.mortbay.jetty.servlet.servletholder.handle(servletholder.java:511)
	at org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1166)
	at org.springframework.web.filter.characterencodingfilter.dofilterinternal(characterencodingfilter.java:88)
	at org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107)
	at org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157)
	at org.mortbay.jetty.servlet.servlethandler.handle(servlethandler.java:388)
	at org.mortbay.jetty.security.securityhandler.handle(securityhandler.java:216)
	at org.mortbay.jetty.servlet.sessionhandler.handle(sessionhandler.java:182)
	at org.mortbay.jetty.handler.contexthandler.handle(contexthandler.java:765)
	at org.mortbay.jetty.webapp.webappcontext.handle(webappcontext.java:418)
	at org.mortbay.jetty.handler.contexthandlercollection.handle(contexthandlercollection.java:230)
	at org.mortbay.jetty.handler.handlercollection.handle(handlercollection.java:114)
	at org.mortbay.jetty.handler.handlerwrapper.handle(handlerwrapper.java:152)
	at org.mortbay.jetty.server.handle(server.java:326)
	at org.mortbay.jetty.httpconnection.handlerequest(httpconnection.java:542)
	at org.mortbay.jetty.httpconnection$requesthandler.headercomplete(httpconnection.java:923)
	at org.mortbay.jetty.httpparser.parsenext(httpparser.java:547)
	at org.mortbay.jetty.httpparser.parseavailable(httpparser.java:212)
	at org.mortbay.jetty.httpconnection.handle(httpconnection.java:404)
	at org.mortbay.io.nio.selectchannelendpoint.run(selectchannelendpoint.java:409)
	at org.mortbay.thread.queuedthreadpool$poolthread.run(queuedthreadpool.java:582)
caused by: java.net.urisyntaxexception: illegal character in scheme name at index 0: 10.150.33.154:8080/getinfo/getuser
	at java.net.uri$parser.fail(uri.java:2848)
	at java.net.uri$parser.checkchars(uri.java:3021)
	at java.net.uri$parser.checkchar(uri.java:3031)
	at java.net.uri$parser.parse(uri.java:3047)
	at java.net.uri.<init>(uri.java:588)
	at java.net.uri.create(uri.java:850)
	... 41 more
disconnected from the target vm, address: '127.0.0.1:65013', transport: 'socket'

process finished with exit code -1

百度了一下,发现好多没用的文章,后来上bing一搜,一下找到了根源,在configuration.xml里面的value前面一定要家http://,否则就会报错~大家放弃百度把,太坑了。

上一篇:

下一篇: