Ich erhalte:RequestParam.defaultValue Wert
aber ich habe MAX_LONG_AS_STRING als Konstante (static final) erklärte:
private static final String MAX_LONG_AS_STRING = Long.toString(Long.MAX_VALUE);
@RequestMapping(method = RequestMethod.GET)
public String spittles(@RequestParam(value = "max", defaultValue = MAX_LONG_AS_STRING) long max,
@RequestParam(value = "count", defaultValue = "20") int count,
Model model) {
model.addAttribute("spittleList", spittleRepository.findSpittles(Long.MAX_VALUE, 20));
return "spittles";
}
Mögliches Duplikat von [Befreie die Meldung "Der Wert für das Annotationsattribut muss ein konstanter Ausdruck sein"] (http://stackoverflow.com/questions/16509065/ge-rid-of-the-value-for-annota-attribute-) muss-ein-konstant-expressio sein n-me) –
Hahaha, das Beispiel stammt eigentlich aus dem Buch "Spring in Action" (https://www.amazon.com/Spring-Action-Covers-4/dp/161729120X/ref=sr_1_1?s=books&ie= UTF8 & qid = 1490873783 & sr = 1-1 & keywords = Frühling + in + Aktion)! – badbishop