Topic: 请教!(usertype=="test" 为false,why?)

  Print this page

1.请教!(usertype=="test" 为false,why?) Copy to clipboard
Posted by: redstarwen
Posted on: 2005-05-07 11:49

请尽量用准确的文字描述作为标题
Dead use equals, not ==



经过测试 usertype值为test!
但以下几句都为false,why?
if(session.getAttribute("usertype")=="test")
if(usertype=="test")
if(rs.getString("usertype")=="test")

2.Re:请教!(usertype=="test" 为false,why?) [Re: redstarwen] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-05-21 14:55

if((String)session.getAttribute("usertype")=="test")
if((String)usertype=="test")
if((String)rs.getString("usertype")=="test")

3.Re:请教!(usertype=="test" 为false,why?) [Re: redstarwen] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-05-21 14:56

比较字符串最好用equals:(

4.Re:请教!(usertype=="test" 为false,why?) [Re: redstarwen] Copy to clipboard
Posted by: kjjx
Posted on: 2005-05-22 00:36

session.getA.. 取出得是Object需要转型才能使用


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923