我的 jspx 页面上的下拉列表有问题。我看到页面上显示了变量值,但我无法获取所选值。输入字符串为空,所以我得到
java.lang.NumberFormatException: For input string: ""
在这一行:
int idRoom = Integer.parseInt(requestInformation.getRequestParameter("idRoom"));
这是我的 jspx 页面:
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
version="2.0">
<jsp:directive.page contentType="text/html; charset=Utf-8"/>
<html>
<head>
<title><fmt:message bundle="${loc}" key="page.newOrders"/></title>
</head>
<body>
<jsp:directive.include file="/jsp/header.jspx"/>
<h2><fmt:message bundle="${loc}" key="label.greeting"/>, ${user.firstName} ${user.lastName}.</h2>
<table cellspacing="15">
<tr>
<td align="center"><b><fmt:message bundle="${loc}" key="field.idOrder"/>:</b></td>
<td align="center"><b><fmt:message bundle="${loc}" key="field.availableRooms"/>:</b></td>
</tr>
<c:forEach items="${orderList}" var="cell">
<tr>
<td align="center">${cell.id}</td>
<c:choose>
<c:when test="${cell.roomList == null}">
<td align="center"><fmt:message bundle="${loc}" key="message.noRooms"/></td>
<td></td>
</c:when>
<c:otherwise>
<form action="Controller" method="get" id="acceptForm">
<td align="center">
<select name="selectedRoom">
<c:forEach items="${cell.roomList}" var="room">
<option value="${room.id}">${room.id}</option>
</c:forEach>
</select>
</td>
<td align="center">
<fmt:message bundle="${loc}" key="button.accept" var="accept"/>
<a href="Controller?command=accept&idOrder=${cell.id}&idRoom=${selectedRoom}" onclick="document.getElementById('acceptForm').submit()">${accept}</a>
</td>
</form>
</c:otherwise>
</c:choose>
<td align="center">
<fmt:message bundle="${loc}" key="message.rejectOrder" var="reject"/>
<c:url value="Controller" var="rejectUrl">
<c:param name="command" value="reject"/>
<c:param name="idOrder" value="${cell.id}"/>
</c:url>
<a href="${rejectUrl}" onClick="return window.confirm('${reject}')">
<fmt:message bundle="${loc}" key="button.reject"/>
</a>
</td>
</tr>
</c:forEach>
</table>
<jsp:directive.include file="/jsp/footer.jspx"/>
</body>
</html>
</jsp:root>