0
我想從android類發送這個url到我的servlet。我寫了servlet的代碼,它捕獲參數的值,但我無法發送這個URL。這是什麼代碼?從android應用程序發送url參數到servlet
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);
URL url;
try {
URL url = new URL("http://localhost:8080/ExtraServ/AssessmentServlet?param1="+lat+lng);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我的servlet代碼:
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");
final String par1 = req.getParameter("param1");
final String par2 = req.getParameter("param2");
FileWriter fstream = new FileWriter("C:\\Users\\Hitchhiker\\Desktop\\out2.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write(par1);
out.append(" ");
out.append(par2);
out.close();