Checking for a not null, not blank String in Java

前端 未结 8 1634
猫巷女王i
猫巷女王i 2021-01-31 13:24

I am trying to check if a Java String is not null, not empty and not whitespace.

In my mind, this code should have been quite up for the job.

         


        
8条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 14:06

    <% 
    System.out.println(request.getParameter("userName")+"*");
    
    if (request.getParameter("userName").trim().length() == 0 | request.getParameter("userName") == null) { %>
    
    <% }
     else { %>
    Hello ${param.userName}
    <%} %>
    

提交回复
热议问题