I have a need of "showing" a word document in a jsp file, and when a user clicks on the file, it should get downloaded.
It is basically a Spring MVC application, the controller creates a word document and then returns the next view to be displayed to the client. This view file (jsp file) should have the word document.
The controller essentially just returns the view name:
@Controller
String handleRequest() {
// Logic for creating a word document.
return "nextView";
}
It is in this nextView.jsp the attachment should appear.
Now, how can we "attach" the generated word document into the jsp file?
Any thoughts in this?
答案 0 :(得分:0)
在页面中使用iframe,您可以再调用一个requestMapping URI,该URI具有设置为excel / word doc的标题内容类型,并且该文档可以在运行中显示。并在iframe之后添加下载链接所示的下载链接。