得到结果后,Struts2是否关闭“ InputStream”?
-
27-10-2019 - |
题
我在struts 2
中有一个动作,它打开一个FileInputStream
,读取图像并将其显示在一个jsp中。
问题是,当struts完成获取图像时,它会自动处理FileInputStream
和close()
还是将流留给open
?
解决方案
Struts2将为您完成输入流后将其关闭。
这是源代码的链接,您可以很好地看到它已经被小心地关闭了流。
以下是同一代码段: 通用标签
希望,您可以清楚地了解事情的进展情况。
其他提示
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
.
不隶属于 StackOverflow