Last active
November 19, 2015 19:59
-
-
Save juanfezero/0fab975dbd2f55b0e02b to your computer and use it in GitHub Desktop.
spring select options with enum - juanfezero -
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Enum example: | |
public enum Foo { | |
A("theA"), B("theB"); | |
private String code; | |
private Foo(String code) { | |
this.code = code | |
} | |
//getter & setter's code | |
} | |
// in a controller method | |
model.addAtribute("foos", Foo.values()); | |
--> | |
<!-- At the jsp --> | |
<form:select id="theId" path="theModelAttributePath"> | |
<form:options items="${foos}" itemLabel="code"/> | |
</form:select> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment