android httpget string url exception java.lang.IllegalArgumentException:索引40处路径中的非法字符

时间:2014-08-27 12:28:07

标签: android http-get illegalargumentexception

读取网页内容有问题 当我打电话给这个网址时:

http://holiday-tricot.com/HOL_And/insert​Comment.php?id=13&comment=mycomment&name=myname

和我的代码:

My Code

当我调用此页面时,它显示我0或1接受评论

错误:

  

08-27 16:40:06.471:E / LogError(16625):异常:   java.lang.IllegalArgumentException:索引处路径中的非法字符   40:   http://holiday-tricot.com/HOL_And/insert Comment.php ID = 13&安培;注释= mycomment&安培;名称= MYNAME   08-27 16:40:06.471:W / System.err(16625):   java.lang.IllegalArgumentException:索引处路径中的非法字符   40:   http://holiday-tricot.com/HOL_And/insert Comment.php ID = 13&安培;注释= mycomment&安培;名称= MYNAME   08-27 16:40:06.478:W / System.err(16625):at   java.net.URI.create(URI.java:727)

     

08-27 16:40:06.478:W / System.err(16625):at   org.apache.http.client.methods.HttpGet。(HttpGet.java:75)

     

08-27 16:40:06.486:W / System.err(16625):at   webservice.Webservice_InsertComments.connectWS(Webservice_InsertComments.java:138)

     

08-27 16:40:06.486:W / System.err(16625):at   webservice.Webservice_InsertComments.doInBackground(Webservice_InsertComments.java:77)

     

08-27 16:40:06.486:W / System.err(16625):at   webservice.Webservice_InsertComments.doInBackground(Webservice_InsertComments.java:1)

     

08-27 16:40:06.494:W / System.err(16625):at   android.os.AsyncTask $ 2.call(AsyncTask.java:264)

     

08-27 16:40:06.494:W / System.err(16625):at   java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:305)

     

08-27 16:40:06.494:W / System.err(16625):at   java.util.concurrent.FutureTask.run(FutureTask.java:137)

     

08-27 16:40:06.494:W / System.err(16625):at   android.os.AsyncTask $ $ SerialExecutor 1.run(AsyncTask.java:208)

     

08-27 16:40:06.494:W / System.err(16625):at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)

     

08-27 16:40:06.502:W / System.err(16625):at   java.util.concurrent.ThreadPoolExecutor中$ Worker.run(ThreadPoolExecutor.java:569)

     

08-27 16:40:06.502:W / System.err(16625):at   java.lang.Thread.run(Thread.java:856)

     

08-27 16:40:06.502:E / LogError(16625):异常:   java.lang.IllegalArgumentException:索引处路径中的非法字符   40:   http://holiday-tricot.com/HOL_And/insert Comment.php ID = 13&安培;注释= mycomment&安培;名称= MYNAME

所以

  

Webservice_InsertComments.java:138

是:我的代码中的第31行

我如何修复它?

谢谢。

删除了零宽度空间 所以它告诉我其他错误:

  

08-27 17:23:24.307:I / LogInfo(19976):url After Replace>>   http://holiday-tricot.com/HOL_And/insertComment.php?id=13&comment=hhhhhh&name=hhhhhh 08-27 17:23:25.822:E / LogError(19976):异常:   org.apache.http.client.ClientProtocolException 08-27 17:23:25.822:   W / System.err(19976):org.apache.http.client.ClientProtocolException   08-27 17:23:25.830:W / System.err(19976):at   org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)   08-27 17:23:25.830:W / System.err(19976):at   org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)   08-27 17:23:25.830:W / System.err(19976):at   org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)   08-27 17:23:25.838:W / System.err(19976):at   webservice.Webservice_InsertComments.connectWS(Webservice_InsertComments.java:137)   08-27 17:23:25.838:W / System.err(19976):at   webservice.Webservice_InsertComments.doInBackground(Webservice_InsertComments.java:74)   08-27 17:23:25.838:W / System.err(19976):at   webservice.Webservice_InsertComments.doInBackground(Webservice_InsertComments.java:1)   08-27 17:23:25.846:W / System.err(19976):at   android.os.AsyncTask $ 2.call(AsyncTask.java:264)08-27 17:23:25.846:   W / System.err(19976):at   java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:305)   08-27 17:23:25.846:W / System.err(19976):at   java.util.concurrent.FutureTask.run(FutureTask.java:137)08-27   17:23:25.853:W / System.err(19976):at   android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:208)08-27   17:23:25.853:W / System.err(19976):at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)   08-27 17:23:25.861:W / System.err(19976):at   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:569)   08-27 17:23:25.861:W / System.err(19976):at   java.lang.Thread.run(Thread.java:856)08-27 17:23:25.869:   W / System.err(19976):引起:   org.apache.http.client.CircularRedirectException:循环重定向到   ' http://holiday-tricot.com/index.php?option=com_content&view=article&id=33'   08-27 17:23:25.877:W / System.err(19976):at   org.apache.http.impl.client.DefaultRedirectHandler.getLocationURI(DefaultRedirectHandler.java:173)   08-27 17:23:25.877:W / System.err(19976):at   org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:923)   08-27 17:23:25.877:W / System.err(19976):at   org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:475)   08-27 17:23:25.877:W / System.err(19976):at   org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)   08-27 17:23:25.885:W / System.err(19976):... 12更多08-27   17:23:25.885:E / LogError(19976):异常:   org.apache.http.client.ClientProtocolException

1 个答案:

答案 0 :(得分:1)

在您的网址C中的insertComment.php之前有一个zero-width space character。删除它。