ERROR: application/pdf is not a supported mime type [duplicate]

假装没事ソ 提交于 2019-11-27 08:08:57

问题


I am using Struts2 and Liferay for developing an application.

My struts.xml is as follows:

<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>

I basically want to download a pdf file from the server. But I get the following error:

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.


回答1:


Looking at the source code seems like only application/vnd.wap.xhtml+xml and text/html are allowed.
Source: http://grepcode.com/file/repo1.maven.org/maven2/com.liferay.portal/portal-impl/6.0.2/com/liferay/portlet/MimeResponseImpl.java




回答2:


Put portletUrlType="resource" to the <s:url> tag which you use to create download link.

<s:url var="downloadUrl" action="download" portletUrlType="resource" />


来源:https://stackoverflow.com/questions/17721094/error-application-pdf-is-not-a-supported-mime-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!