读书人

两个对象的比较批改密码验证:直接写

发布时间: 2013-08-04 18:26:16 作者: rapoo

两个对象的比较,修改密码验证:直接写在jsp里的

两个对象的比较,修改密码验证:直接写在jsp里的
我先把这问题给解决了再说
别让我换的js 啥啥的 当然添加点有用的东西学习也不错!

//其实就是2个string对象的比较,所以要用equal,“==”是简单类型的比较,
//jsp中"=="主要是用于数字的比较,一般比较字符串都是用equal.
之前没用equal时候有问题,发现是对象比较问题,然后用了
写了2个循环都不好使,咋回事

String newpaswd1 =new String (request.getParameter("newpaswd1").getBytes("ISO-8859-1"),"UTF-8");
String newpaswd2=new String (request.getParameter("newpaswd1").getBytes("ISO-8859-1"),"UTF-8");



// if(newpaswd1.equals("")||newpaswd2.equals("")){
// out.println("<script>alert('新密码不能为空!');location.href='update.jsp'</script>");

// }else if(newpaswd1.equals(newpaswd2)){
// out.println("<script> alert('确定更改密码?');window.location='updateNew.jsp'</script>");
// }else{
// out.println("<script> alert('两次密码不一致,请重新输入!');window.location='update.jsp'</script>");
// }


。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

if(!(newpaswd1.equals("") && newpaswd2.equals(""))){
if(newpaswd1.equals(newpaswd2)){
out.println("<script> alert('确定更改密码?');window.location='updateNew.jsp'</script>");
}else{
out.println("<script> alert('两次密码不一致,请重新输入!');window.location='update.jsp'</script>");
}
}else{
out.println("<script>alert('新密码不能为空!');location.href='update.jsp'</script>");
}
JSP String 对象 验证


[解决办法]
newpaswd1 ,newpaswd2 都是从request.getParameter("newpaswd1").取的取同一个值啊

读书人网 >Java Web开发

热点推荐