gpt4 book ai didi

java - 使用displayTag导出到pdf,excel,xml, Spring 不工作

转载 作者:行者123 更新时间:2023-12-01 09:54:38 25 4
gpt4 key购买 nike

我在 jsp 中使用显示标记,但它不起作用。我使用 spring MVC 框架作为后端。也许jsp无法识别显示标签。我已经包含了 Spring 和显示标签所需的所有 jar 。

我的jsp代码:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>

</head>

<body>

<div>
<c:if test="${not empty recordList}">
<display:table id="txt" pagesize="10" requestURI="" name="recordList">
<display:column property="trafficType"></display:column>
<display:column property="publisherId"></display:column>
<display:column property="publisherName"></display:column>
<display:column property="publisherGroupDevice"></display:column>
<display:column property="clicks"></display:column>
<display:column property="cost"></display:column>
<display:column property="merchantSales"></display:column>
</display:table>
</c:if>
</div>

</body>

</html>

我的 Controller 包含这一行

model.addAttribute("recordList", recordList);

我在控制台上收到此错误

    INFO  aytag.export.ExportViewFactory - Initializing ExportViewFactory with type={csv,excel,xml,pdf}
2016-05-19 22:35:55,660 [http-bio-8080-exec-2] INFO tag.properties.TableProperties - No LocaleResolver configured.
2016-05-19 22:35:55,698 [http-bio-8080-exec-2] INFO tag.properties.TableProperties - I18nResourceProvider initialized to org.displaytag.localization.I18nJstlAdapter.
2016-05-19 22:35:55,891 [http-bio-8080-exec-2] ERROR nextagBase.jsp - forwarding to URL (iDChnl == null): /serv/main/serv/main/internal/v1/generateReport failed.
java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:348)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
at nextag.api.Jsp.forward(Jsp.java:4472)

最佳答案

如此处所述 java.lang.IllegalStateException: Cannot forward / sendRedirect after response has been committed可能是由于在 sendRedirect(); 之后调用 forward(); 引起的如果您有以下情况,这可能是在无意中完成的:

protected void doPost() {
if (someCondition) {
sendRedirect();
}
forward(); // This is STILL invoked when someCondition is true!
}

即使条件为 true,forward 方法也会在 sendRedirect 后调用

关于java - 使用displayTag导出到pdf,excel,xml, Spring 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37341011/

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