search

Home  >  Q&A  >  body text

Java前台input如果什么都不输入的话,后台获取到的是空字符串,如何让让变成null呀?

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

怪我咯怪我咯2802 days ago1497

reply all(7)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 09:57:38

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

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:57:38

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

    reply
    0
  • 阿神

    阿神2017-04-18 09:57:38

    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

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:57:38

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

    //daima

    }

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:57:38

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

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:57:38

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

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 09:57:38

    Check if it is empty and assign null

    reply
    0
  • Cancelreply