错误:应用程序/pdf 不是受支持的 mime 类型 [英] ERROR: application/pdf is not a supported mime type
问题描述
我正在使用 Struts2 和 Liferay 开发应用程序.
I am using Struts2 and Liferay for developing an application.
我的struts.xml
如下:
<action name="download" class="com.stp.portal.view.DownloadAction">
<result name="success" type="stream">
<param name="contentType">application/pdf</param>
<param name="inputName">fileInputStream</param>
<param name="contentDisposition">attachment;filename="abc.pdf"</param>
<param name="bufferSize">1024</param>
</result>
</action>
我基本上想从服务器下载一个 pdf 文件.但我收到以下错误:
I basically want to download a pdf file from the server. But I get the following error:
10:05:55,782 错误 [Jsr168Dispatcher:38] 无法执行操作java.lang.IllegalArgumentException: application/pdf 不是受支持的 mime 类型在 com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:159)...
10:05:55,782 ERROR [Jsr168Dispatcher:38] Could not execute action java.lang.IllegalArgumentException: application/pdf is not a supported mime type at com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:159)...
不知道如何解决.真的很感激有人的帮助.确实需要这样做.
Don't know how to resolve this. Would really appreciate someone's help. Really need this to be done.
推荐答案
把 portletUrlType="resource"
放到你使用的 <s:url>
标签中创建下载链接.
Put portletUrlType="resource"
to the <s:url>
tag which you use to create download link.
<s:url var="downloadUrl" action="download" portletUrlType="resource" />
这篇关于错误:应用程序/pdf 不是受支持的 mime 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!