Ivan Pavlov
02/21/2020, 12:13 PM@GetMapping
fun get(@RequestParam(required = false) limit: Int = 10): String {
return limit.toString()
}
java.lang.IllegalStateException: Optional int parameter 'limit' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
Different approach works fine but I would like to avoid it:
@GetMapping
fun get(@RequestParam(required = false, defaultValue = "10") limit: Int): String {
return limit.toString()
}