0

我有以下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 以获得所需的结果?

4

1 回答 1

1

form:options标签对此具有特殊属性(itemLabel):

<form:select path="terminalStatus">
    <form:options items="${allStatuses}" itemLabel="label"/>
</form:select>
于 2015-07-18T19:33:20.550 回答