Java Ho获取HTTP输入字段值,并使用c:if进行一些测试
我这里有一个SpringMVC应用程序。当菜单页面打开时,我将放置两个模型属性:menuList和orderList。menuList由数据库中的信息填充,orderList是空列表,我希望在客户机提交动态表单时将其完全填充。我知道如何绑定订单列表中菜单中的所有产品,但那将是浪费。。。很多事情。我需要做的是检查每个产品旁边动态附加的输入字段“pieces”的值或长度是否大于0。我该怎么做Java Ho获取HTTP输入字段值,并使用c:if进行一些测试,java,html,jsp,jstl,Java,Html,Jsp,Jstl,我这里有一个SpringMVC应用程序。当菜单页面打开时,我将放置两个模型属性:menuList和orderList。menuList由数据库中的信息填充,orderList是空列表,我希望在客户机提交动态表单时将其完全填充。我知道如何绑定订单列表中菜单中的所有产品,但那将是浪费。。。很多事情。我需要做的是检查每个产品旁边动态附加的输入字段“pieces”的值或长度是否大于0。我该怎么做 <c:url value="/menu/order" var="orderPath"/> <
<c:url value="/menu/order" var="orderPath"/>
<form:form action="${orderPath}" method="POST" modelAttribute="orderList">
<table>
<tr>
<th>Name</th>
<th>Code</th>
<th>Price</th>
<th>Description</th>
<th>Calories</th>
<th>Image</th>
<th>Pieces</th>
</tr>
<c:set var="index" value="0" scope="page" />
<c:forEach items="${menuList}" var="menu" varStatus="i">
<tr>
<td>${menu.name}</td>
<td>${menu.code}</td>
<td>${menu.price}</td>
<td>${menu.description}</td>
<td>${menu.calories}</td>
<td><img src="<c:url value="/images/${menu.image}" />" alt="" width=120></td>
<td><input type="text" name="pieces"></td>
<!-- i need to take the "pieces" input field value here and check it if,
lets say, the length is greater than 0 (or the value is greater than 0)
and to make data binding only in those situations
I saw something like <c:if test="${param.pieces}>0"> but that's not working
or maybe i'm doing some kind of mistake, i don't know
-->
<!--start: this code should be executed if the condition is evaluated to true -->
<form:hidden path="orderList[${index}].orderID"/>
<form:hidden path="orderList[${index}].menuID" value="${menu.menuID}"/>
<form:hidden path="orderList[${index}].pieces" value="**value-of-pieces-input-field**"/>
<c:set var="index" value="${index + 1}" scope="page" />
<!--end -->
</tr>
</c:forEach>
<tr>
<td colspan="2">
<input type="submit" value="Make an order"/>
</td>
</tr>
</table>
</form:form>
名称
代码
价格
描述
卡路里
形象
件
${menu.name}
${menu.code}
${menu.price}
${menu.description}
${menu.carries}
“alt=”“width=120>
你很接近了
<c:if test="${param.pieces > 0 }">
<form:hidden path=.../>
</c:if>
JSTL函数可能会有所帮助-您能更具体一些吗?