如何使用 Struts2 上传 Microsoft Word .docx 和 .xlsx 文件 [英] How to upload Microsoft word .docx and .xlsx files using Struts2
问题描述
我们在我们的应用程序中使用 Struts2,我使用 struts2 上传功能进行文件上传.现在我的要求是,我们需要让用户上传到.docx"和.xlsx".我在 strut.xml 中将application/msword"和application/vnd.ms-excel"列为 allowedTypes
.通过这种方式,我们可以仅上传.doc"和.xls"文件,但不能上传.docx"和.xlsx"文件.有什么解决方法吗?
We are using Struts2 in our application and I am using the struts2 upload functionality for file uploading. Now my requirement is, we need to let the user upload to ".docx" and ".xlsx". I listed "application/msword" and "application/vnd.ms-excel" as allowedTypes
in strut.xml. By this we are able to upload only ".doc" and ".xls" files, but not ".docx" and ".xlsx" files. Is there any workaround for this?
推荐答案
来自 http://sanjaal.com/java/tag/microsoft-office-2010-mime-types/
以下是用于 MS Office 2010 文档文件格式的 MIME 类型.
The following are the mime types to be used for MS Office 2010 document file formats.
.docm: application/vnd.ms-word.document.macroEnabled.12
.docx: application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotm: application/vnd.ms-word.template.macroEnabled.12
.dotx: application/vnd.openxmlformats-officedocument.wordprocessingml.template
.potm: application/vnd.ms-powerpoint.template.macroEnabled.12
.potx: application/vnd.openxmlformats-officedocument.presentationml.template
.ppam: application/vnd.ms-powerpoint.addin.macroEnabled.12
.ppsm: application/vnd.ms-powerpoint.slideshow.macroEnabled.12
.ppsx: application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptm: application/vnd.ms-powerpoint.presentation.macroEnabled.12
.pptm: application/vnd.ms-powerpoint.presentation.macroEnabled.12
.pptx: application/vnd.openxmlformats-officedocument.presentationml.presentation
.xlam: application/vnd.ms-excel.addin.macroEnabled.12
.xlsb: application/vnd.ms-excel.sheet.binary.macroEnabled.12
.xlsb: application/vnd.ms-excel.sheet.binary.macroEnabled.12
.xlsm: application/vnd.ms-excel.sheet.macroEnabled.12
.xlsx: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltm: application/vnd.ms-excel.template.macroEnabled.12
.xltx: application/vnd.openxmlformats-officedocument.spreadsheetml
.xps: application/vnd.ms-xpsdocument
这篇关于如何使用 Struts2 上传 Microsoft Word .docx 和 .xlsx 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!