无法将值与java中的httpResponse进行比较

时间:2013-07-17 10:27:03

标签: java json

我之前在这里提交了我的问题,现在我的问题是当我发布到localhost这个代码工作正常,当我连接服务器时,它无法正常工作。服务器php脚本与localhosts php文件相同,并返回相同的值。这是我的代码。 Login.java

        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response;
        HttpPost httppost = new HttpPost("http://www.def.net/login.php");
        StringEntity se = new StringEntity(obj.toString());
        httppost.setEntity(se);
        System.out.println(se);
        httppost.setHeader("Accept", "application/json");
        httppost.setHeader("Content-type", "application/json");


        response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        String s = EntityUtils.toString(entity);
        System.out.println(s);

        if(s.equals("1")){
            //open new home window
        }else{
            //print error message
        }

0 个答案:

没有答案