错误:应用程序/pdf 不是受支持的 mime 类型 [英] ERROR: application/pdf is not a supported mime type

查看:21
本文介绍了错误:应用程序/pdf 不是受支持的 mime 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆