Skip to main content
deleted 234 characters in body
Source Link
bbuljj
  • 113
  • 7

you can add your CustomException and add exceptionHandler

@ControllerAdvice Classtry to override handleMethodArgumentTypeMismatch

@ExceptionHandler({TestExceptionMethodArgumentTypeMismatchException.class}) public ResponseEntity<Object> testExceptionhandleMethodArgumentTypeMismatch(TestException eMethodArgumentTypeMismatchException ex, ServletWebRequestWebRequest request) {  ...  return new ResponseEntity();  } 

Custom Exception class

public class TestException extends RuntimeException { public TestException() { super(); } public TestException(String message) {  super(message); } } 

you can add your CustomException and add exceptionHandler

@ControllerAdvice Class

@ExceptionHandler({TestException.class}) public ResponseEntity<Object> testException(TestException e, ServletWebRequest request) {  ...  return new ResponseEntity();  } 

Custom Exception class

public class TestException extends RuntimeException { public TestException() { super(); } public TestException(String message) {  super(message); } } 

try to override handleMethodArgumentTypeMismatch

@ExceptionHandler({MethodArgumentTypeMismatchException.class}) public ResponseEntity<Object> handleMethodArgumentTypeMismatch( MethodArgumentTypeMismatchException ex, WebRequest request) { return ResponseEntity } 
Source Link
bbuljj
  • 113
  • 7

you can add your CustomException and add exceptionHandler

@ControllerAdvice Class

@ExceptionHandler({TestException.class}) public ResponseEntity<Object> testException(TestException e, ServletWebRequest request) { ... return new ResponseEntity(); } 

Custom Exception class

public class TestException extends RuntimeException { public TestException() { super(); } public TestException(String message) { super(message); } }