gpt4 book ai didi

java - Displaytag 导出选项不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 01:59:01 63 4
gpt4 key购买 nike

我正在使用 Displaytag 框架进行分页和导出。因为我也在使用 Strut2Tiles Integration。

每当我调用任何 Action 类时,它都会返回一个列表并通过 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.jar2) displaytag-export-poi-1.2.jar3) 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).

请回复,我被这个问题困住了。

最佳答案

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

关于java - Displaytag 导出选项不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/842845/

63 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com