SpringBoot里获取出错项目的项目名和错误消息

  • A+
所属分类:SpringBoot
List err = result.getFieldErrors();
FieldError fe;
String field;
String errorMessage;
for (int i = 0; i < err.size(); i++) {
fe = (FieldError) err.get(i);
// 取得项目名
field = fe.getField();
// 取得错误消息
errorMessage = fe.getDefaultMessage();
}

 

ZPY

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: