Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 124 characters in body
Source Link
soulcheck
  • 36.9k
  • 6
  • 95
  • 91

The problem here is that spring tries to convert date string to Date and fails. When that happens TypeMismatchException (which wraps IllegalArgumentException, which in turn wraps ParseException) is thrown and you should handle that instead of NumberFormatException.

IfWhen you changechanged the exception typeclass to Exception it getsgot handled, as TypeMismatchException inheritsextends Exception.

IfA tip: if you're using any logging framework, try turning debug logging on for spring mvc classes, it can clear things up a lot.

For example put something like this in your lo4j.propeties:

log4j.logger.org.springframework.servlet=DEBUG 

The problem here is that spring tries to convert date string to Date and fails. When that happens TypeMismatchException (which wraps IllegalArgumentException, which in turn wraps ParseException) is thrown and you should handle that instead of NumberFormatException.

If you change the exception type to Exception it gets handled as TypeMismatchException inherits Exception.

If you're using any logging framework, try turning debug logging on for spring mvc classes, it can clear things up a lot.

The problem here is that spring tries to convert date string to Date and fails. When that happens TypeMismatchException (which wraps IllegalArgumentException, which in turn wraps ParseException) is thrown and you should handle that instead of NumberFormatException.

When you changed the exception class to Exception it got handled, as TypeMismatchException extends Exception.

A tip: if you're using any logging framework, try turning debug logging on for spring mvc classes, it can clear things up a lot.

For example put something like this in your lo4j.propeties:

log4j.logger.org.springframework.servlet=DEBUG 
Source Link
soulcheck
  • 36.9k
  • 6
  • 95
  • 91

The problem here is that spring tries to convert date string to Date and fails. When that happens TypeMismatchException (which wraps IllegalArgumentException, which in turn wraps ParseException) is thrown and you should handle that instead of NumberFormatException.

If you change the exception type to Exception it gets handled as TypeMismatchException inherits Exception.

If you're using any logging framework, try turning debug logging on for spring mvc classes, it can clear things up a lot.