小弟我在做校园网登录客户端的时候遇到这个样的有关问题,

我在做校园网登录客户端的时候遇到这个样的问题,求助。。。点击退出登录的时候发送一个POST请求来退出登录,但

我在做校园网登录客户端的时候遇到这个样的问题,求助。。。
点击退出登录的时候发送一个POST请求来退出登录,但是有时候(不是每次)会出现下面的情况(LogCat):
我该怎么写才能获取这个Invalid redirect URI呢?

10-12 20:34:12.586: W/System.err(6515): org.apache.http.client.ClientProtocolException
10-12 20:34:12.586: W/System.err(6515): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)
10-12 20:34:12.590: W/System.err(6515): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
10-12 20:34:12.590: W/System.err(6515): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
10-12 20:34:12.590: W/System.err(6515): at com.mysoft.login4u.HttpPostService.sendPostRequest(HttpPostService.java:92)
10-12 20:34:12.590: W/System.err(6515): at com.mysoft.login4u.Logined$1$1.run(Logined.java:42)
10-12 20:34:12.590: W/System.err(6515): Caused by: org.apache.http.ProtocolException: Invalid redirect URI: http://202.202.96.57:9030?action=22&login_time=2012-10-12 18:27:39&logout_time=2012-10-12 20:34:11&money2=0.0
10-12 20:34:12.590: W/System.err(6515): at org.apache.http.impl.client.DefaultRedirectHandler.getLocationURI(DefaultRedirectHandler.java:116)
10-12 20:34:12.590: W/System.err(6515): at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:923)
10-12 20:34:12.593: W/System.err(6515): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:475)
10-12 20:34:12.593: W/System.err(6515): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
10-12 20:34:12.593: W/System.err(6515): ... 4 more
10-12 20:34:12.593: W/System.err(6515): Caused by: java.net.URISyntaxException: Illegal character in query at index 57: http://202.202.96.57:9030?action=22&login_time=2012-10-12 18:27:39&logout_time=2012-10-12 20:34:11&money2=0.0
10-12 20:34:12.593: W/System.err(6515): at libcore.net.UriCodec.validate(UriCodec.java:63)
10-12 20:34:12.593: W/System.err(6515): at java.net.URI.parseURI(URI.java:406)
10-12 20:34:12.593: W/System.err(6515): at java.net.URI.<init>(URI.java:204)
10-12 20:34:12.597: W/System.err(6515): at org.apache.http.impl.client.DefaultRedirectHandler.getLocationURI(DefaultRedirectHandler.java:114)
10-12 20:34:12.597: W/System.err(6515): ... 7 more

这部分的代码如下:

Java code
public static boolean sendPostRequest() {        HttpPost httpRequest = new HttpPost(loginURL_2);        try {            HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);            if (httpResponse.getStatusLine().getStatusCode() == 200) {                return true;            } else {                Log.d("error", "Error Response: "                        + httpResponse.getStatusLine().toString());            }        } catch (ClientProtocolException e) {            Log.d("ex", "1");            e.printStackTrace();        } catch (IOException e) {            Log.d("ex", "2");            e.printStackTrace();        } catch (IllegalStateException e) {            Log.d("ex", "3");            e.printStackTrace();        } catch (Exception e) {            Log.d("ex", "4");            e.printStackTrace();        }        return false;    }


[解决办法]
10-12 20:34:12.593: W/System.err(6515): Caused by: java.net.URISyntaxException: Illegal character in query at index 57: 
http://202.202.96.57:9030?action=22&login_time=2012-10-12 18:27:39&logout_time=2012-10-12 20:34:11&money2=0.0
uri中index 57的位置是字符串“2012-10-12 18:27:39”中日期12后的空格,检查uri没通过,所以抛出异常。
后面还有一个这样的空格。
------解决方案--------------------


服务端谁写的哦?
登陆登出时间哪有客户端传参的哟?
要是我手机时间调成公元前,那是不是说明出鬼了?
这样记录时间有意义么?
赶快叫人改服务器的代码,而且这个异常肯定不只手机端会触发,其他客户端也会触发。
服务器端不改,你这边改了,那边也识别不了,所以别白费心思了~跟人沟通下吧
[解决办法]
url 被空格截断了,服务器可能认为参数不合法拒绝连接
最合理的方法是在服务器端获取登入登出时间,这样避免了客户端时间不一致的问题
实在不好改的话 客户端对登入登出时间encode一下,服务器收到后decode一下就ok了。