【发布时间】:2014-12-17 14:08:24
【问题描述】:
尝试从我的 jsp 中的项目获取值时出现以下异常。
以下是我的错误:
SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/Dashboard] threw exception [An exception occurred processing JSP page /WEB-INF/jsp/chartListFromDB.jsp at line 9
6: <c:if test="${not empty chart_items}"></c:if>
7:
8: <c:forEach var="chartList" items="${chart_items}">
9: <li><a href="/Dashboard/chart/displayChart/${chart_items.chartId}">${chart_items.chartName}</a>
10: </li>
11: </c:forEach>
12: </ul>
Stacktrace:] with root cause
java.lang.NumberFormatException: For input string: "chartId" at java.lang.NumberFormatException.forInputString(Unknown Source)
这是我的控制器
@RequestMapping(value = "/availableChartsFromDB", method = RequestMethod.GET)
public String availableChartsFromDB(ModelMap model) {
IChartBehaviour chartService = new ChartService();
List<Chart> chart_items = chartService.getAvilableChartsFromDB();
model.addAttribute("chart_items", chart_items);
return "chartListFromDB";
}
这是我的 JSP
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@include file="header.jsp"%>
<div id="content_main">
<h3>Chart Selector ...</h3>
<ul>
<c:if test="${not empty chart_items}"></c:if>
<c:forEach var="chartList" items="${chart_items}">
<li><a href="/Dashboard/chart/displayChart/${chart_items.chartId}">${chart_items.chartName}</a>
</li>
</c:forEach>
</ul>
</div>
<%@include file="footer.jsp"%>
【问题讨论】:
标签: jsp spring-mvc jstl