背景
今天在项目中自定义异常输出时候,发现 ex.getPropertyName 始终是null,查阅资料找到解决办法
private String getPropertyName(TypeMismatchException mismatchException) {if (mismatchException instanceof MethodArgumentTypeMismatchException) {return ((MethodArgumentTypeMismatchException)mismatchException).getName();}return mismatchException.getPropertyName();}
