Advertisement
ILyaCyclone

Untitled

Nov 18th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. контроллер:
  2.  
  3. @RestController
  4. public class NewsController {
  5.  
  6. @GetMapping("/data/test")
  7. public String test(
  8. @RequestParam(name="id_binding", required = false) Integer idBinding
  9. ) {
  10. return "ok";
  11. }
  12. }
  13.  
  14.  
  15.  
  16. открываю в браузере:
  17. http://localhost:9050/data/test?id_binding=null
  18.  
  19.  
  20. ошибка:
  21. There was an unexpected error (type=Bad Request, status=400).
  22. 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"
  23.  
  24.  
  25. консоль:
  26. 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"
  27.  
  28.  
  29.  
  30.  
  31. а так работает:
  32. http://localhost:9050/data/test?id_binding=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement