我想将此 url 从一个 android 类发送到我的 servlet。我已经为 servlet 编写了代码,它捕获了参数的值,但我无法发送这个 url。执行此操作的代码是什么?
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();
}
我的小服务程序代码:
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();