Parts of the (Java, Spring-mvc, JSP) Form input is checked by Javascript. The rest is done by a custom Validator. The problem is when the Javascript validation is prevented, such an error may be printed:
Failed to convert property value of type java.lang.String to required type java.lang.Long for property xxx; nested exception is java.lang.NumberFormatException: For input string: "x"
是否有更好的办法处理转换问题。 当贾瓦-瓦解者接手时,它已经遇到转换错误,或者现在还有可能加以核对?
编辑:主计长内部的协调人代码。
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, true));
}
但其真正公正的标准功能(org. Cerframework.beans.propertyeditors.CustomNumberEditor)和我认为必须有一个简单的解决办法,因为它似乎是一个共同的东西,可以长期反对某些杂质,并试图将其排除在外(或赶走)。