两个对象的比较,修改密码验证:直接写在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>");
}
JSPString对象验证
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货