Grails 如何在浏览器中打开文档

Grails 如何在浏览器中打开文档,grails,grails-2.0,Grails,Grails 2.0,我正在尝试在浏览器中打开word文档。所以,当用户想要查看它时,我应该能够在浏览器本身中打开文档。有没有办法做到这一点 现行代码: response.addHeader("Content-Type", "application/msword; charset=utf-8") response.addHeader("Content-disposition", "inline; filename="+"\"testdoucment.doc\"") response.setContentLength(

我正在尝试在浏览器中打开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()
response.addHeader(“内容类型”,“应用程序/msword;字符集=utf-8”)
response.addHeader(“内容处置”、“内联;文件名=“+”\“testdoucment.doc\”)
response.setContentLength(content.getBytes().length)

response.outputStream您拥有的代码应该会导致文档被下载。您无法再在浏览器中打开Word文档。我想,你以前在IE 5或6中也能做到,但仅此而已

关于如何实现你所说的目标,但这两个答案都没有被投票或接受。不过,我确信它必须由用户设置。你不能仅仅通过改变响应来强迫它以那种方式打开