-1

是否有任何枪击方法来查找和检查空字符串而不会出现异常?

请不要建议 StringUtils 类。我尝试了一切,但我无法用项目编译它。我正在使用 Tomcat,我在 tomcat 的根文件夹中进行编程,并且我有几个无法与 StringUtils 链接的 jsp 文件。我正在使用 Dreamweaver 进行编程。

请帮忙,

4

2 回答 2

1

通常的方式有什么问题吗?

if (str == null)

如果“null”也表示“空白”,那么

if (str == null || str.trim().isEmpty())
于 2013-07-09T05:34:42.057 回答
0

如果您想在 jsp 中使用类似函数,请执行以下操作:

<%!
 // define a isNull() function
 static boolean isNull(String x){
    return (x == null || x.isEmpty());
 }
%>

then you can use above function anywhere inside JSP like 

<% if (isNull(xxx)){ %>
// html code
<% } %>
于 2013-07-09T05:44:23.267 回答