Spring form tag select的选中问题

        <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>


如果是新增,这个cargo.cargoType是为空,使用上面的那个情况就会报null错。怎么才能把上面两个给合并成一个呢??

你可能感兴趣的:(java,spring,jsp,struts)