public class IactionAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
IactionForm iactionForm = (IactionForm) form;// TODO Auto-generated method stub
String name=iactionForm.getUsername();
String pass=iactionForm.getPassword();
ActionMessages err=new ActionMessages();

Session session=HibernateSessionFactory.getSession();
String sqls="select {sel.*} from t_temp sel where username=:thename";
SQLQuery sqlq=session.createSQLQuery(sqls);
sqlq.addEntity("sel", User.class);
sqlq.setString("thename",name);
List list=sqlq.list(); 
Iterator it=list.iterator();
User user=(User)it.next();
String temppsw=user.getPassword();
HibernateSessionFactory.closeSession();
System.out.println(pass.toString());
System.out.println(temppsw.toString());
System.out.println(temppsw.toString()==pass.toString());
if("".equals(name.trim()) || "".equals(pass.trim())){ 
// || pass.toString()!=temppsw.toString()
if("".equals(name.trim())){
err.add("username", new ActionMessage("error.name.required",name));
}
if("".equals(pass.trim())){
err.add("password", new ActionMessage("error.password.required",pass));
}
saveErrors(request, err);
return mapping.findForward("fail");
}else{
return mapping.findForward("success");
}
}
}
我想实现用户登陆, 核对用户 用户名和密码是不是正确;
这段
                System.out.println(pass.toString());
System.out.println(temppsw.toString());
System.out.println(temppsw.toString()==pass.toString());
输出为:
123456
123456
false为什么都是123456却还是false,是编码问题吗?