ILyaCyclone icon

Untitled

ILyaCyclone | PRO | 11/18/18 04:21:36 PM UTC | 0 ⭐ | 571 👁️ | Never ⏰ | []
text |

1.07 KB

|

None

|

0 👍

/

0 👎

контроллер:
 @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

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎