spring接收Integer的問題

正常情況下,使用包裝類型可以避免傳空時報錯,但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: ""]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章