我在jsp中使用display标签,但它不起作用。我正在使用spring MVC框架作为后端。 也许jsp无法识别显示标签。我已经包含了弹簧和展示标签所需的所有罐子。
我的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>
我的控制器包含这一行
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)
答案 0 :(得分:1)
此处所述java.lang.IllegalStateException: Cannot forward / sendRedirect after response has been committed
可能是因forward();
之后拨打sendRedirect();
而引起的
如果您有以下情况,这可能是在不知不觉中完成的:
protected void doPost() {
if (someCondition) {
sendRedirect();
}
forward(); // This is STILL invoked when someCondition is true!
}
,forward
方法将在sendRedirect
之后调用,即使条件为真
答案 1 :(得分:0)
对不起,我发布了这个问题;但经过大量的调试后,我发现显示标签没有从控制器中获取正确的列表数据结构,这是我的错误,所以我纠正了它,代码运行得很好。