Displaytag导出选项不起作用

时间:2009-05-09 07:03:13

标签: java struts2

我正在使用Displaytag框架进行分页&出口目的。因为我也在使用Strut2Tiles Integration。

每当我打电话给任何一个动作课时,它都会给我一个清单&通过Displaytag我在我的页面上成功显示记录。为此,我的jsp页面代码如下:

  <s:set name="selectedPageSize" value="selectedPageSize" scope="request"/>
        <s:set value="accountList" scope="request" name="accountList"/>
            <display:table name="accountList" export="true" class="table" requestURI="" id="accountList" pagesize="${selectedPageSize}" >
            <display:setProperty name="export.pdf" value="true" /> 
            <display:column property="id" sortable="true" class="sort-title"/>
            <display:column property="name" sortable="true"/>
            <display:column property="contactPerson" sortable="true"/>
            <display:column property="phone1" sortable="true"/>
            <display:column property="phone2" sortable="true"/>
            <display:column property="fax" sortable="true"/>
            <display:column property="email" sortable="true"/>
            <display:column property="webSite" sortable="true"/>
            <display:column property="address1" sortable="true"/>
            <display:column property="address2" sortable="true"/>
            <display:column property="countryId.name" title="Country" sortable="true"/>
            <display:column property="stateId.name" title="State" sortable="true"/>
            <display:column property="countryId.name" title="City" sortable="true"/>

            <display:column property="isDeleted" sortable="true"/>

            <display:column title="Delete">
                <s:url id="removeUrl" action="finance/deleteAccount.action">
                    <s:param name="id" value="#attr.accountList.id" />
                </s:url>
                <s:a href="%{removeUrl}" theme="ajax" targets="accountList">Remove</s:a>
            </display:column>

            <display:column  title="Update">
                <s:url id="updateUrl" action="finance/updateAccount.action">
                    <s:param  value="#attr.accountList.id" name="id"/>
                </s:url>
                <s:a href="%{updateUrl}&action=update" targets="accountlist">Update</s:a>
            </display:column>

实际上这个页面是通过图块配置显示的。

这里我启用了导出选项,因此它向我显示了CSV,EXCEL,XML等导出选项。但是,当我点击该CSV链接时,我的网络浏览器被挂起,意味着没有显示任何内容

对于该导出解决方案,我还在我的web.xml中添加了过滤器。我的web.xml看起来像:

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
  <filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
</filter-mapping>

<listener>
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/webApplicationContext.xml</param-value>
</context-param>

<welcome-file-list>
    <welcome-file>jsp/welcome.jsp</welcome-file>
</welcome-file-list>

我还包括以下displaytag库列表: 1)displaytag-1.2.jar 2)displaytag-export-poi-1.2.jar 3)displaytag-portlet-1.2.jar

我得到的例外是:

2009-05-09 12:02:38,234 DEBUG (org.displaytag.tags.TableTag:1524) - Exportfilter NOT enabled
2009-05-09 12:02:38,312  WARN (org.displaytag.tags.TableTag:63) - Exception: [.TableTag] Unable to reset response before returning exported data. You are not using an export filter. Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3).
ApplicationDispatcher[/PaginationTry2] PWC1231: Servlet.service() for servlet jsp threw exception
Exception: [.TableTag] Unable to reset response before returning exported data. You are not using an export filter. Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3).

Plz回复,我遇到了这个问题。

2 个答案:

答案 0 :(得分:6)

您是否尝试过对web.xml中的过滤器进行重新排序,以便DisplayTag的ResponseOverrideFilter是链中的第一个过滤器,即在struts2过滤器之前?

答案 1 :(得分:1)

配置您的displaytag表:

<display:table name="sessionScope.searchProviderLRSharingList"
id="row"
requestURI="/**ACTION_MAPPING_CALLED_TO_GET_THE_RESULTS**"
...
...
</display:table>

在web.xml中配置过滤器:

<filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>

    ResponseOverrideFilter     的 ACTION_MAPPING_CALLED_TO_GET_THE_RESULTS