What's the best way to suppress a runtime console warning in Java?

前端 未结 7 1409
情歌与酒
情歌与酒 2021-02-07 07:15

I am using the getResponseBody() method of the org.apache.commons.httpclient.methods.PostMethod class. However, I am always getting a message written to the console at runtime:

相关标签:
7条回答
  • 2021-02-07 08:21

    that warning happends when httpClient have no idea about the length of the return data you should set the content-length attribute in your server end

    response.addHeader("Content-Type", "text/html; charset=utf-8");
    response.addHeader("Content-Length", String.valueOf(output.getBytes("utf8").length));
    

    after that, that warning should disapear

    0 讨论(0)
提交回复
热议问题