How can we export jsp to doc file using conte开发者_JS百科nt type?
You can set the content type of a JSP via setContentType
:
response.setContentType("application/msword");
You'll want to be sure not to output anything from the JSP other than the data making up the Word document. And you'll want to check that MIME type; this is my source for the above, which is for one variant of Word files, but I think there's a more canonical MIME type I'm not finding (using "vnd"). And the type for .docx files is different, Microsoft says here that it's (deep breath) application/vnd.openxmlformats-officedocument.wordprocessingml.document
.
精彩评论