Spring CustomNumberEditor解析不是数字的数字

Spring CustomNumberEditor解析不是数字的数字,第1张

Spring CustomNumberEditor解析不是数字的数字

由于它依赖于NumberFormat类,该类将停止在第一个无效字符处解析输入字符串,所以我认为您必须扩展NumberFormat类。

首先脸红是

public class StrictFloatNumberFormat extends NumberFormat {  private void validate(in) throws ParseException{     try {       new Float(in);     }     catch (NumberFormatException nfe) {       throw new ParseException(nfe.getMessage(), 0);       }  public Number parse(String in) throws ParseException {    validate(in);    super.parse(in);  }  ..... //any other methods}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5441994.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存