Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Joby KJ
Struts2 file download is not working in liferay portlet
September 21, 2012 7:11 AM
Answer

Joby KJ

Rank: Junior Member

Posts: 43

Join Date: July 13, 2012

Recent Posts

Hi,
I am trying to download pdf file in my liferay portlet , which is developed using struts2. I am getting following error.

java.lang.IllegalArgumentException: application/pdf is not a supported mime type
at com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:159)
at org.apache.struts2.portlet.servlet.PortletServletResponse.setContentType(Portl
at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:248)
..........................
.....................
.....................


Here i my configurations.

struts.xml
------------------

<action name="download" class="com.test.action.MyAction" >
<result name="success" type="stream">
<param name="contentType">application/pdf</param>
<param name="inputName">fileData</param>
<param name="contentDisposition">attachment;filename=="document.pdf"</param>
</result>
</action>

Action class
------------------------

private InputStream fileData;

public InputStream getFileData() {
return fileData;
}

public String execute() throws Exception {

fileData = new FileInputStream(new File("D:\\text.pdf"));

return SUCCESS;
}




Thanks
Joby
Joby KJ
RE: Struts2 file download is not working in liferay portlet
September 24, 2012 12:39 AM
Answer

Joby KJ

Rank: Junior Member

Posts: 43

Join Date: July 13, 2012

Recent Posts

Any idea ?
Joby KJ
RE: Struts2 file download is not working in liferay portlet
October 10, 2012 12:22 AM
Answer

Joby KJ

Rank: Junior Member

Posts: 43

Join Date: July 13, 2012

Recent Posts

Still facing that problem. Any suggestion will be a great help.