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

2

3

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.

Cembalo answered 18/7, 2013 at 10:34 Comment(6)
which server are you using?Serpent
Which liferay version? Are you using Jsr286Dispatcher?Norvun
Liferay 6.1 . No, i am not using Jsr286DispatcherCembalo
@AleksandrM, according to his Exception, he's using Jsr168DispatcherDorsiventral
See if this help; it is for Spring MVC, maybe it can be adapted to Struts2.Dorsiventral
@AndreaLigios: Jsr286Dispatcher extends Jsr168Dispatcher so it class name maybe used in logs.Norvun
L
0

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

Lipp answered 18/7, 2013 at 10:42 Comment(1)
Is there any way to do it? I want to download a pdf file from server. I have already lost 2 days in this.Cembalo
N
0

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

<s:url var="downloadUrl" action="download" portletUrlType="resource" />
Norvun answered 18/7, 2013 at 12:42 Comment(4)
not working for me, same errorCembalo
@user2594235: Just tested, works for me. Have you re-deployed your portlet correctly? Liferay tends to cache everything. Also which version of Struts2 and portlet plugin?Norvun
i hv redeployed the portlet, but still not working, i m using portlet pugin 2.2.3Cembalo
@user2594235: You could try with latest version, but AFAIK it should work in older versions also. Are you sure that changes are reflected in JSP? Try to change some text and see. Also post generated url.Norvun

© 2022 - 2024 — McMap. All rights reserved.