我有以下jsp:
<form:select path="terminalStatus">
<form:options items="${allStatuses}"/>
</form:select>
它呈现如下:
<select id="terminalStatus" name="terminalStatus">
<option value="ACTIVE" selected="selected">ACTIVE</option>
<option value="INACTIVE">INACTIVE</option>
</select>
我希望它会有所不同。像这样:
<select id="terminalStatus" name="terminalStatus">
<option value="ACTIVE" selected="selected">label_1</option>
<option value="INACTIVE">label_2</option>
</select>
实际上allstatuses
是TerminalStatus
:
public enum TerminalStatus {
ACTIVE("label_1"), INACTIVE("label_2");
String label;
public String getLabel() {
return label;
}
private TerminalStatus(String label) {
this.label = label;
}
}
spring form允许自定义我的jsp以获得所需的结果吗?
答案 0 :(得分:1)
form:options
标记具有此特殊属性(itemLabel
):
<form:select path="terminalStatus">
<form:options items="${allStatuses}" itemLabel="label"/>
</form:select>