If a client sends a request with parameter not matching the endpoints parameter type,there will throw TypeMismatchException .
@RestController
public class DemoController {
@GetMapping("/test")
public String demo(Long id) {
return "success";
}
clients send requests to the "/test?id=undefined" .
error logs :
org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "undefined"
at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:133) ~[spring-web-5.2.8.RELEASE.jar!/:5.2.8.RELEASE]
According to this log, I can't locate which requestMpping is the problem.
what I expecting in logs:
at class DemoController.demo,Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long'; nested exception is java.lang.NumberFormatException: For input string: "undefined"
Comment From: rstoyanchev
This is handled in DefaultHandlerExceptionResolver
and we don't log exceptions that are handled. Where is the log message logged from? The exception itself provides access to the MethodParameter
.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.