daily pastebin goal
39%
SHARE
TWEET

Untitled

ILyaCyclone Nov 18th, 2018 (edited) 91 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top