Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有来自 Servlet 的值和我收到的参数之一
request.getParameterValues("Names");
我将其分配给
String names[] = null; names = request.getParameterValues("Names");
我正在通过以下方式检查名称是否为空,但是即使它为空,我的条件也没有得到执行。这可能是什么原因?
if(names!= null)
我正在检查名称是否为空
所以应该是if(names == null)
if(names == null)
最好检查null一下参数,例如request.getParameterValues("Names")
null
request.getParameterValues("Names")
String names[] = null; if(request.getParameterValues("Names")!=null){ names = request.getParameterValues("Names"); }