正常情況下,使用包裝類型可以避免傳空時報錯,但JavaBean中需要不只改類型,同樣要改set方法中的傳參類型,否則報如下錯誤:
org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'zcPersonsDto' on field 'fcancel': rejected value [];
codes[typeMismatch.zcPersonsDto.fcancel,typeMismatch.fcancel,typeMismatch.in,
typeMismatch];arguments[org.springframework.context.support.DefaultMessageSou
rceResolvable:codes [zcPersonsDto.fcancel,fcancel]; arguments []; default
message [fcancel]];default message [Failed to convert property value of type
'java.lang.String' to required type 'int' for property 'fcancel';nested
exception is java.lang.NumberFormatException: For input string: ""]