0

只是一个简单的快速问题。我想在我的 HTTP 请求中传递一个日期。日期格式是这样的22\July\2012。这是我要传递的 URL。在哪里dateChat =22\July\2012

if(this.dateChat!="") {
  this.dateChat.replace("\\", "\\\\");
}
httpclient= new DefaultHttpClient();
httpget = new HttpGet("http://10.116.27.107/php/Chat/xmlManipulator.php?" +
  "action="+this.action+"&username="+this.userName+
  "&chatText="+this.chatText+"&email="+this.email+
  "&callfrom="+this.callFrom+"&dateChatToRetrieve="+this.dateChat);

logcat 给出以下错误:

 07-15 20:26:40.165: E/AndroidRuntime(2000): FATAL EXCEPTION: main
 07-15 20:26:40.165: E/AndroidRuntime(2000): java.lang.IllegalArgumentException:
  Illegal character in query at index 146:
  http://10.116.27.107/php/Chat/xmlManipulator.php?action=ReturnUserAdminChats&username=You&chatText=a&email=You&callfrom=admin&dateChatToRetrieve=5\July\2012
4

1 回答 1

2

使用URLEncoder.encode()对 dateChat 进行编码

于 2012-07-15T15:47:21.523 回答