<appfuse:label styleClass="desc" key="cargoType.cargoTypeName"/>
<form:errors path="cargoType" cssClass="fieldError"/>
<c:choose>
<c:when test="${not empty cargo.cargoType}">
<form:select path="cargoType.cargoTypeId" cssClass="text medium" cssErrorClass="text medium error" id="cargoTypeId" >
<form:option value="" label="Please Select"/>
<form:options items="${cargoTypeList}" itemValue="cargoTypeId" itemLabel="cargoTypeName"/>
</form:select>
</c:when>
<c:otherwise>
<select name="cargoTypeId" id="cargoTypeId">
<option value="">Please Select</option>
<c:forEach var="cargoType" items="${cargoTypeList}" varStatus="status">
<option value="${cargoType.cargoTypeId}">${cargoType.cargoTypeName}</option>
</c:forEach>
</select>
</c:otherwise>
</c:choose>
<form:errors path="cargoType" cssClass="fieldError"/>
<c:choose>
<c:when test="${not empty cargo.cargoType}">
<form:select path="cargoType.cargoTypeId" cssClass="text medium" cssErrorClass="text medium error" id="cargoTypeId" >
<form:option value="" label="Please Select"/>
<form:options items="${cargoTypeList}" itemValue="cargoTypeId" itemLabel="cargoTypeName"/>
</form:select>
</c:when>
<c:otherwise>
<select name="cargoTypeId" id="cargoTypeId">
<option value="">Please Select</option>
<c:forEach var="cargoType" items="${cargoTypeList}" varStatus="status">
<option value="${cargoType.cargoTypeId}">${cargoType.cargoTypeName}</option>
</c:forEach>
</select>
</c:otherwise>
</c:choose>
Cargo Type Select
该段代码展示了如何使用 JSP 和 JSTL 进行货品类型的选择框构建,其中包括了使用 form:select 和 c:forEach 循环来动态生成选项。
360

被折叠的 条评论
为什么被折叠?



