这是java ME中的servlet代码。
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
ArrayList<String> listName = new ArrayList<String>();
ArrayList<Integer> listLongitude = new ArrayList<Integer>();
ArrayList<Integer> listLatitude = new ArrayList<Integer>();
String sLongitude = (String) request.getParameter("x");
String sLatitude = (String) request.getParameter("y");
String path, list, scount;
Integer numLong = null;
Integer numLati = null;
Connection con = null;
String slanje = "";
int limitLeft, limitRight, limitUp, limitDown, icount = 0;
if (sLongitude != null && sLatitude != null) {
try {
numLong = Integer.valueOf(sLongitude);
numLati = Integer.valueOf(sLatitude);
} catch(Exception ex) {}
}
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:derby://localhost:1527/bazaprojekt", "projekt2009", "midlet");
limitLeft = numLong - 8;
limitRight = numLong + 8;
limitUp = numLati + 8;
...
如何将x和y发送到servlet并在Android中接收一些字符串?
答案 0 :(得分:2)
在Servlet的URL之后,只需将它们作为请求参数传递给查询字符串:
http://example.com/context/servlet?x=123&y=456
。
答案 1 :(得分:1)
如果您正在使用PostMethod,可以使用PostMethod.addParameter设置它们。