这是我的代码(.jsp 文件)
<div class="form-group">
<label for="state">State</label>
<form:select class="form-control input-sm" id="state"
path="state">
<form:option value="">Select</form:option>
<form:options items="${States.getStates()}" />
</form:select>
</div>
枚举是:
public enum States {
Andhra_Pradesh("Andhra Pradesh"),
Arunachal_Pradesh("Arunachal Pradesh"),
Assam("Assam"),
Bihar("Bihar"),
Chhattisgarh("Chhattisgarh"),
Delhi("Delhi"),
West_Bengal("West Bengal");
private String stateName;
private static Map<States, String> states;
private States(String stateName) {
this.stateName = stateName;
}
static {
states = new LinkedHashMap<>();
for (States state : States.values()) {
states.put(state, state.getStateName());
}
}
public static Map<States, String> getStates() {
return states;
}
public String getStateName() {
return stateName;
}
}
在本地它可以正常工作,例如:(html源代码)
<select id="state" path="state" class="form-control input-sm">
<option value="Andhra_Pradesh">Andhra Pradesh</option>
<option value="Arunachal_Pradesh">Arunachal Pradesh</option>
....
</select>
但是当我在 aws 上部署时,它看起来像:
<select id="state" path="state" class="form-control input-sm">
<option value="Andhra_Pradesh">Andhra_Pradesh</option>
<option value="Arunachal_Pradesh">Arunachal_Pradesh</option>
....
</select>
注意下划线(_)。我希望这与本地工作相同。如果有人对此有任何想法,请提供帮助。