所以当我用
发帖子请求时httpClient.execute(httpPost)
我得到以下输出:
09:09:12.181 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "username=qliu&password=213%40vPi" # <==== THIS LINE
09:09:12.283 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
我的密码实际上是213@vPi
而不是213%40vPi
但我不知道如何逃避&#34; @&#34;符号
String password = "213@vPi"; // TODO: how to escape @
答案 0 :(得分:0)
使用StringEntity类来代替。
HttpPost prepareLoginHttpPost() {
HttpPost httpPost = new HttpPost(Configurations.SAND_LOGIN_URL);
StringEntity authorizationInJSON_Entity = new StringEntity(Configurations.authorizationInJSON);
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
httpPost.setEntity(authorizationInJSON_Entity);
return httpPost;
}