如果用户在系统中没有设置,我正在尝试向我的 Spring JSP 添加一些代码以显示自治市镇列表。
这是我的 JSP 代码:
<form:hidden path="borough" />
<c:choose>
<c:when test="${empty borough}">
<tr>
<td width="129"><span class="ast">*</span>Borough: </td>
<td width="361">
<form:select path="borough">
<form:option value="Staten Island">Staten Island</form:option>
<form:option value="Queens">Queens</form:option>
<form:option value="Brooklyn">Brooklyn</form:option>
<form:option value="Bronx">Bronx</form:option>
<form:option value="Manhattan">Manhattan</form:option>
</form:select>
</td>
</tr>
</c:when>
<c:otherwise>
<form:hidden path="borough" />
</c:otherwise>
</c:choose>
c:choose 之前的隐藏字段仅用于调试。这是我的输出:
<input id="borough" name="borough" type="hidden" value="Queens"/>
<tr>
<td width="129"><span class="ast">*</span>Borough: </td>
<td width="361">
<select id="borough" name="borough">
<option value="Staten Island">Staten Island</option>
<option value="Queens" selected="selected">Queens</option>
<option value="Brooklyn">Brooklyn</option>
<option value="Bronx">Bronx</option>
<option value="Manhattan">Manhattan</option>
</select>
</td>
</tr>
所以看起来它认为自治市镇总是空的?