gpt4 book ai didi

java - Java 中如何检查 null 值?

转载 作者:行者123 更新时间:2023-12-01 17:38:19 25 4
gpt4 key购买 nike

如何在JSP中查找值是否为null。例如。在下面我想检查管道表中的描述列是否有空值。

String Query1 = "SELECT description FROM pipe where pipe_id='" + id+"' and version_id=2";
SQLResult = SQLStatement.executeQuery(Query1);
SQLResult.first();
description = SQLResult.getString("description");
if(description=="")
{
json_string=json_string+"&desc="+description;
out.println("not null");
} else
{
json_string=json_string;
out.println("null");
}

最佳答案

嗯: if (description != null && !description.isEmpty()) ...但是您是在 JSP 中编写此代码吗?这似乎是错误的。您可能应该在 servlet 中执行此操作,并将描述作为请求属性传递给 jsp。

关于java - Java 中如何检查 null 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4027464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com