帮助。执行 PostMethod.getStatusCode() 时出现异常!

发布于 2024-09-09 10:35:57 字数 685 浏览 3 评论 0原文

无法弄清楚为什么我在这里得到空指针:System.out.println(method.getStatusCode()); !? 方法初始化并成功执行! 有什么想法吗? 示例代码在这里。我正在使用 commons-httpclient-3.1.jar

            PostMethod = new PostMethod(url);

        LogInHelper.logRequest(httpClient, method);

        try {
            httpClient.executeMethod(method);
            method.getResponseBodyAsString();
        } catch (HttpException e) {
            LOG.error("@getSessionId() error connecting to " + url, e);

        } catch (IOException e) {
            LOG.error("@getSessionId() error connecting to " + url, e);

        }

        LogInHelper.logResponse(method);

        System.out.println(method.getStatusCode());

Couldn't figure out why I'm getting Null pointer here : System.out.println(method.getStatusCode()); !?
method initialized and successfully executed!
Any ideas?
Sample code here. I'm using commons-httpclient-3.1.jar

            PostMethod = new PostMethod(url);

        LogInHelper.logRequest(httpClient, method);

        try {
            httpClient.executeMethod(method);
            method.getResponseBodyAsString();
        } catch (HttpException e) {
            LOG.error("@getSessionId() error connecting to " + url, e);

        } catch (IOException e) {
            LOG.error("@getSessionId() error connecting to " + url, e);

        }

        LogInHelper.logResponse(method);

        System.out.println(method.getStatusCode());

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虚拟世界 2024-09-16 10:35:57

在这种情况下,清理并重新编译整个项目会有所帮助。

Cleaning and recompile whole project helped in this case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文