-1

如何在我的网址中添加字符串?例如:

String Password="123";
String UserName="şlk";

HttpGet httppost = new HttpGet("http://192.168.2.245/getProducts.php?login=1&user_name=UserName&user_pass=Password");  

但它通过这种方式给出了错误。怎么可能?

4

3 回答 3

2

You can do it simply by + operator

HttpGet httppost = new HttpGet( "URL/getProducts.php?login=1&user_name="+UserName+"&user_pass="+Password);

于 2013-10-08T13:23:18.073 回答
1

这是一个简单的字符串操作:

String url = "http://192.168.2.248/getProducts.php?login=1&user_name="+ UserName + "&user_pass=" + Password;
HttpGet httppost = new HttpGet(url);

请多了解 Java,给你买一本书,然后继续 google!

于 2013-10-08T13:25:52.093 回答
0

use concatenation operator it is "+" in java "." in php

HttpGet httppost = new HttpGet("...&user_name="+UserName+"&user_pass="+Password); 

please read java before using it. style guide as well.

于 2013-10-08T13:24:50.860 回答