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

前端 未结 7 1411
情歌与酒
情歌与酒 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

提交回复
热议问题