0

我正在尝试在浏览器中打开一个 word 文档。因此,当用户想要查看它时,我应该能够在浏览器本身中打开文档。有没有办法做到这一点?

现在的代码:

response.addHeader("Content-Type", "application/msword; charset=utf-8")
response.addHeader("Content-disposition", "inline; filename="+"\"testdoucment.doc\"")
response.setContentLength(content.getBytes().length)
response.outputStream<<content.bytes
response.outputStream.flush()
response.flushBuffer()
4

1 回答 1

2

您拥有的代码应该会导致文档被下载。您无法再在浏览器中打开 Word 文档。我认为你曾经能够在 IE 5 或 6 中做到这一点,但仅此而已。

这是一个关于如何实现您所说的内容的问题,但没有一个答案被赞成或接受。不过,我确信它必须由用户设置。您不能仅通过更改响应来强制它以这种方式打开。

于 2013-07-24T12:19:38.063 回答