Is it possible to set possible values for @RequestParam(value = "id") String id)
?
The ideal is: I give some List<String> allowedValues and it automatically validate it. (This list will be loaded from database).
use an enum instead of a String and define your enum values
@RequestMapping(value = "yourRestEndPoint", method = RequestMethod.GET)
public anyReturnType methodName(@RequestParam(defaultValue = "ONE") IdValue id) {
....
}
and have a separate class defined e.g
public enum IdValue {
ONE, TWO, THREE
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With