我在struts 2中有一个动作,它打开一个FileInputStream,读取图像并将其显示在一个jsp中。

问题是,当struts完成获取图像时,它会自动处理FileInputStreamclose()还是将流留给open

有帮助吗?

解决方案

Struts2将为您完成输入流后将其关闭。

这是源代码的链接,您可以很好地看到它已经被小心地关闭了流。

Struts2 StreamResult源代码

以下是同一代码段: 通用标签

希望,您可以清楚地了解事情的进展情况。

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top