如何在我的网址中添加字符串?例如:
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");
但它通过这种方式给出了错误。怎么可能?
You can do it simply by + operator
HttpGet httppost = new HttpGet( "URL/getProducts.php?login=1&user_name="+UserName+"&user_pass="+Password);
这是一个简单的字符串操作:
String url = "http://192.168.2.248/getProducts.php?login=1&user_name="+ UserName + "&user_pass=" + Password;
HttpGet httppost = new HttpGet(url);
请多了解 Java,给你买一本书,然后继续 google!
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.