Java前台input如果什么都不输入的话,后台获取到的是空字符串,如何让让变成null呀?
怪我咯
怪我咯 2017-04-18 09:55:38
0
7
1491

前台不输入,如何让后台获取到的是null?我想获取null

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(7)
大家讲道理

Use js to determine whether the value is empty before submitting. If it is empty, assign null

伊谢尔伦

When submitting, wouldn’t it be enough to remove the name of the empty input?

阿神

When you pass the value from the front-end drop-down box to the back-end, if you don't select it, the attribute will be assigned a value of "". You can just judge this on the backend. Normally, the frontend will pass "" for processing

Peter_Zhu

Why must it be null? The default is ""
if(x!=null && x!equals("")){

//daima

}

刘奇
if(x.length>0){
    //TODO
}
刘奇

It is recommended to use Google’s guava library which has the emptyToNull method under strings

大家讲道理

Check if it is empty and assign null

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template