当前位置: 技术问答>java相关
关于session的问题
来源: 互联网 发布时间:2017-03-14
本文导语: String regist_message=null; regist_message=(String) session.getAttribute("login_message");//第一运行login_message还没有设置; if ((regist_message != null)||(regist_message != "")) { session.setAttribute("login_message",""); out.println(""); out.println(reg...
String regist_message=null;
regist_message=(String) session.getAttribute("login_message");//第一运行login_message还没有设置;
if ((regist_message != null)||(regist_message != ""))
{
session.setAttribute("login_message","");
out.println("");
out.println(regist_message);
out.println("
"); regist_message=(String) session.getAttribute("login_message");//第一运行login_message还没有设置;
if ((regist_message != null)||(regist_message != ""))
{
session.setAttribute("login_message","");
out.println("");
out.println(regist_message);
out.println("
}
为什么运行结果会打印出null来?
|
if ((regist_message != null) && (regist_message != ""))
|
if ((regist_message != null) && (!regist_message.equals("")))
java中字符串比较最好用equals()
java中字符串比较最好用equals()