java Spring 3 错误消息的含义和解决方案?“推荐使用 getResponseBodyAsStream”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3713412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Meaning and solution for Spring 3 error message? "Using getResponseBodyAsStream instead is recommended"
提问by Linc
I'm using Spring 3 and every time I submit a HTML form to a Spring controller I get this message, which I don't understand:
我正在使用 Spring 3,每次我向 Spring 控制器提交 HTML 表单时,我都会收到这条消息,我不明白:
org.apache.commons.httpclient.HttpMethodBase getResponseBody
WARNING: Going to buffer response body of large or unknown size.
Using getResponseBodyAsStream instead is recommended.
Is there a configuration change I can make in Spring to avoid this?
我可以在 Spring 中进行配置更改来避免这种情况吗?
回答by earldouglas
This occurs with the commons-httpclient API when the getResponseBody() method is used. The warning means that a response body could potentially be very large (such as a large file download, etc.) and loading the whole thing into memory at once as a String could be very inefficient. The way to avoid this potential inefficiency is to use getResponseBodyAsStream(), which will allow proper buffering and streaming of the response body.
当使用 getResponseBody() 方法时,commons-httpclient API 会发生这种情况。该警告意味着响应主体可能非常大(例如大文件下载等),并且将整个内容作为字符串一次加载到内存中可能非常低效。避免这种潜在低效率的方法是使用 getResponseBodyAsStream(),这将允许对响应主体进行适当的缓冲和流式处理。
I am not sure why Spring is using getResponseBody(). Could it be your HTTP client? Are you using a custom-written HTTP client to perform the request?
我不确定为什么 Spring 使用 getResponseBody()。它可能是您的 HTTP 客户端吗?您是否使用自定义编写的 HTTP 客户端来执行请求?
回答by Angle Tom
You can add configuration http.method.response.buffer.warnlimit=1024*1024*10
in the application.properties. it works for me.
您可以http.method.response.buffer.warnlimit=1024*1024*10
在 application.properties 中添加配置。这个对我有用。