如何在会话中找到值设置为变量?
if(session.getAttribute("tot_demand"))//need to change
//if value is already set then do this.
else
//if not set then do this.
我需要编写什么才能使上述代码生效?
答案 0 :(得分:6)
与null
比较:
if (session.getAttribute("tot_demand") != null) {
// already set
} else {
// not yet set
}