How could I display the values of enum structure in JSP? I use the Spring MVC to implement my project.
Many thanks!
public enum ProjectStatusEnum {
INITIAL(0,"Initial"),ONGOING(1,"Ongoing"),CLOSED(2,"Closed");
private int value;
private String key;
ProjectStatusEnum(int value , String key){
this.value=value;
this.key = key;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
Add the enum values in an attribute of your request:
And finally, within your JSP:
Define in your ModelAttribute class the variable to bind to the type of your ENUM class
In the controller, put an instance of YourCommand yourCommand into Model
On your jsp page,