Displaytag export option is not working- Solution
In this article we will learn to resolve the issue which occurs while exporting the file using display tag,
In order to enable export functionality in display tag, configure display tag in JSP as shown below.
<display:table name="studentList" pagesize="5" export ="true" requestURI="/displaytag.jsp"> <display:column property="rollNo" title="Roll No"/> <display:column property="studentName" title="Student Name"/> <display:column property="department" title="Department"/> <display:column property="rank" title="Rank"/> </display:table>
Here export=”true” option enable export functionality in displaytag.
Displaytag Export Issue
After enabling displaytag export functionality, though it was working in test program, export option on display tag for CSV, Excel, XML and PDF was not working on actual project.
** UPDATE: Struts 2 Complete tutorial now available here.
My Application throws the following exception and error message, when user clicks on export button :
org.displaytag.exception.BaseNestableJspTagException
Cause of Displaytag export problem:
This issue occurs when you have declared filter in web.xml
Solution :
To fix displaytag export issue the following steps are needed to be followed:
Add ResponseOverrideFilter filter as shown below.
<filter> <filter-name>ResponseOverrideFilter</filter-name> <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class> </filter> <filter-mapping> <filter-name>ResponseOverrideFilter</filter-name> <url-pattern>*.*</url-pattern> </filter-mapping>
Make sure that display tag’s ResponseOverrideFilter placed as first filter in web.xml
Related Questions:
How to make Struts 2 tag work inside Display tag?
How to get checkbox values from displaytag using struts2