private static HttpPost getHttpPost(String url) {
HttpPost hp = new HttpPost(url);
return hp;
}
private static HttpResponse getHttpResponse(HttpPost httpPost) throws ClientProtocolException, IOException{
HttpResponse hr = new DefaultHttpClient().execute(httpPost);
return hr;
} public static String sendGetRequest(String path, Map<String, String> map, String enc) throws Exception{

String fanhui = "false";
HttpPost request = getHttpPost(path);

        List<NameValuePair> parameters = new ArrayList<NameValuePair>();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            NameValuePair nameValuePairs = new BasicNameValuePair(entry.getKey(), entry.getValue());
            parameters.add(nameValuePairs);
        } 
        
      
        HttpEntity entity = new UrlEncodedFormEntity(parameters, "utf-8");
        request.setEntity(entity);

HttpResponse response = getHttpResponse(request); if(response.getStatusLine().getStatusCode() == 200){
fanhui = "true";
//fanhui = EntityUtils.toString(response.getEntity());
}
System.out.println("返回的值为:" + fanhui);
return fanhui;


这是我的客户端。public class LoginDao extends HttpServlet {

protected void login(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException, ClassNotFoundException {
// TODO Auto-generated method stub
resp.setContentType("text/html;charset=UTF-8");
PrintWriter pw = resp.getWriter();
Boolean str = true;
pw.println(str);
pw.flush();
pw.close();
}}
这是我的服务端。mainifest设置了internet权限了。
我在另一个类中调用了sendGetRequest方法,返回的值总是为“false”,这是什么原因,有人能解答吗?AndroidURL数据库HTTP