【发布时间】:2013-11-24 20:59:18
【问题描述】:
我开发了一个 ios 应用程序,现在也可以作为 android 应用程序实现。 我是 android 新手,但 url 格式有问题。
我通过以下代码在 ios 中输入 uname 和 pwd 信息:
NSString *checkForLogin = [NSString stringWithFormat:[[@"http://" stringByAppendingString:IP] stringByAppendingString: @"&what=LoginCheck.php&un=%@&pwd=%@" ],username.text,pwd.text];
对于 android,我没有通过使用以下代码获得正确的最终 url:
nameValuePairs.add(new BasicNameValuePair("un", un.getText().toString()));
nameValuePairs.add(new BasicNameValuePair("pwd", pwd.getText().toString()));
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(constants.URL + "&what=LoginCheckJava.php" );
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF_8"));
最终的url应该是:xxxxxxxx/loadhtml.php?where=DeliverySystem&what=LoginCheck.php&un=usertest&pwd=1234567890
请帮忙。谢谢
【问题讨论】: