I have a spring boot controller, one of my parameters is an Enum. The enum has a string value. I want to pass as the parameter the value of the enum and the controller to give me the Enum. Can this be done?
@RequestMapping(value = "/")
public MyResponse getResponse ( @RequestParam(value = "version") final ProjectVersion version ) {
...bla bla bla...
}
public enum ProjectVersion {
VERSION_1 ("1.00")
VERSION_2 ("2.00")
private final String version;
ProjectVersion ( String version ) {
this.version = version;
}
@Override
public String toString() {
return this.version;
}
}
I want to be able to make a request as follows:
http://myhost.com/mypath?version=1.00
And get in the controller the ProjectVersion.VERSION_1
Any ideas?