我从 HTML 向 servlet 发送数据,它会成功运行。
但从 Android 开始,它将传递给下一个Intent。Servlet 将显示"NULL",没有数据。
谁能告诉我我错在哪里?谢谢!
小服务程序代码:
public class SocialServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException{
this.doPost(request,response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
String json_array = request.getParameter("array");
out.println(json_array);
}
}
安卓代码:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://192.168.1.103:8080/social/social.do");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("array", "teststring"));
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);