String userId = request.getParameter("userId");
HttpClient http = new HttpClient();
String returnJson="";
try {
PostMethod method = new PostMethod(url);
method.addParameter("userId", userId); //传递参数
http.executeMethod(method);
returnJson = method.getResponseBodyAsString(); //返回结果
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Charset", "UTF-8");
PrintWriter out = response.getWriter();
out.print(returnJson);
out.flush();
out.close();
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HttpClient http = new HttpClient();
String returnJson="";
try {
PostMethod method = new PostMethod(url);
method.addParameter("userId", userId); //传递参数
http.executeMethod(method);
returnJson = method.getResponseBodyAsString(); //返回结果
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Charset", "UTF-8");
PrintWriter out = response.getWriter();
out.print(returnJson);
out.flush();
out.close();
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}