Struts2是否关闭“InputStream”?他们得到结果后?
我在 struts 2
中有一个操作,它打开一个 FileInputStream
,读取图像并将其显示在 jsp 中。
问题是,当struts完成获取图像后,它会自动处理FileInputStream
并close()
它还是保持流open< /代码>?
I have an action in struts 2
where it opens an FileInputStream
, reads an image and shows it in a jsp.
The question is that when struts is finished with getting the image, will it automatically take care of the FileInputStream
and close()
it or the stream is left open
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
结果将关闭输入流;所有操作所做的就是提供流。一旦操作返回,您的代码将不再控制输入流。
相关代码位于
org.apache.struts2.dispatcher.StreamResult:doExecute
中。The result will close the input stream; all the action does is provide the stream. Your code no longer has control of the input stream once the action returns.
Relevant code is in
org.apache.struts2.dispatcher.StreamResult:doExecute
.一旦 Struts2 完成了工作,它就会负责关闭输入流。
这是源代码的链接,您可以清楚地看到已经小心地关闭了流。
Struts2 StreamResult 源代码
以下是相同的代码片段:
希望能让您清楚地了解事情是如何进行的。
Struts2 will take care of closing the input stream once it has done the work for you.
Here is the link to the source code and you can very well see that it has been taken care to close the stream.
Struts2 StreamResult Source Code
Here is the code snippet from the same:
Hope will give you clear idea how things are going underway.