0

我正在尝试编写一个使用 HTTP GET 方法的 JSON 客户端,我得到了 500 的响应。我尝试过的代码如下,有什么问题吗?我尝试设置的请求参数是 entityName= Nila 和 parentEntity=500000001 作为参数。

URL url = new URL("http://192.168.210.74:9763/services/testEntityService?entityName=Nila&parentEntity=500000001");



        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");
        conn.setRequestProperty("Accept", "application/json");

        if (conn.getResponseCode() != 200) {
            throw new RuntimeException("Failed : HTTP error code : "
                    + conn.getResponseCode());
        }

        BufferedReader br = new BufferedReader(new InputStreamReader(
                (conn.getInputStream())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            System.out.println(output);
        }

        conn.disconnect();

    } catch (MalformedURLException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }

}
4

1 回答 1

1

它是一个内部服务器错误,是的,问题出在服务器端。

于 2013-06-17T16:23:43.103 回答