-3
我想做一个基于php页面的应用程序,发送给它的参数通过php页面从远程db获取数据。java和php获取请求
我会用jsons,但我的问题是:
假设我用这个代码发送请求:
URL url = new URL("http://www.francescorizzi.altervista.org/Main.php?Request=Login&UserName=mario&Password=lol");
URLConnection conn = url.openConnection();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
我应该重新创建URL对象,康涅狄格州,并在每个新请求RD?还是有更有效的方法来做到这一点?
请注意:我是通过java处理HTTP的新手。
你想用java或用PHP构建应用程序吗? – monterico
[使用java.net.URLConnection触发和处理HTTP请求]可能的重复(http://stackoverflow.com/questions/2793150/using-java-net-urlconnection-to-fire-and-handle-http-requests ) –
@monterico该应用程序是在Java中,数据通过PHP检索。 –