контроллер:
@RestController
public class NewsController {
@GetMapping("/data/test")
public String test(
@RequestParam(name="id_binding", required = false) Integer idBinding
) {
return "ok";
}
}
открываю в браузере:
http://localhost:9050/data/test?id_binding=null
ошибка:
There was an unexpected error (type=Bad Request, status=400).
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "null"
консоль:
2018-11-18 20:19:27.479 WARN 26864 --- [nio-9050-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "null"
а так работает:
http://localhost:9050/data/test?id_binding=1
Comments
0 B
|👍
/👎