看看一段jsp登录代码

luckboy1017 2004-09-09 03:32:00
while(rs.next())
{ String strstr=rs.getString(1);
out.print(buttonName);
out.print(strstr);
out.print(buttonPass);
if(strstr.equals(buttonPass))
{out.print(buttonPass);
response.sendRedirect("Nteacher.jsp");

}
else{out.print("it is wrong"); }
}
}
catch(SQLException e){System.out.print(e);}


其中butonName 是用户输入的用户名
strstr是数据库里返回的拥护密码
buttonPass 是拥护输入的密码,
已经输出来strstr和buttonpass的值一样
可结果是
apple pple pple it is wrong
怎么就不跳转呀,一夜拉,救救我吧
...全文
182 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
luckboy1017 2004-09-09
  • 打赏
  • 举报
回复
是string
rainworm 2004-09-09
  • 打赏
  • 举报
回复
你的buttonPass是什么类型的
String的吗?
luckboy1017 2004-09-09
  • 打赏
  • 举报
回复
pple我有说明的
jspxnet 2004-09-09
  • 打赏
  • 举报
回复
rs.getString(1) 内容看看是什么
Bluecatr 2004-09-09
  • 打赏
  • 举报
回复
将trim()换个地方也行呀,主要是对从数据库中取出的string值去掉后面的空格尾巴,
String strstr=rs.getString(1);

if(strstr.trim().equals(buttonPass.trim()))
luckboy1017 2004-09-09
  • 打赏
  • 举报
回复
楼上第一条语句报错
xuyang821225 2004-09-09
  • 打赏
  • 举报
回复
String strstr=rs.getString(1).trim();

if(strstr.equals(buttonPass.trim()))
xsp 2004-09-09
  • 打赏
  • 举报
回复
楼主用了连续的三个out.print()语句,而结果是“apple pple pple it is wrong”,中间有多个空格,就说明三个字符串的内容中有空格。细心些,很容易发现问题的。

81,117

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧