String sql = "select * from UserTbl where userName = " + userName +
" and " + "password=" + password;
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
boolean flag = rs.next();
if (flag == true) {
response.sendRedirect(
"http://localhost/LoginManage/success.html"); } else {
response.sendRedirect(
"http://localhost/LoginManage/nosuccess.html");
out.println("已经成功登陆");
}
请高手执教以下。错误
" and " + "password=" + password;
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
boolean flag = rs.next();
if (flag == true) {
response.sendRedirect(
"http://localhost/LoginManage/success.html"); } else {
response.sendRedirect(
"http://localhost/LoginManage/nosuccess.html");
out.println("已经成功登陆");
}
请高手执教以下。错误
解决方案 »
- ssh整合问题 No getter method for property skuname of bean
- 性能测试时GC中的老生代满了。。响应超慢
- 为什么会HTTP Status 404 - Servlet action is not available
- 拦截器拦截不到异步提交的数据
- 循环问题,,,好慢~谁有更快的办法?
- 急救!!!!!!!!!多谢大家了!!!!!!!!!!!!!!!!!在线等
- struts 中如何使用gzip压缩网页,代码写在哪里?
- mysql4.0中文乱码问题
- 框架网页参数传递问题,up有分
- location.replace("/module/rili/index_en.jsp");响应很慢甚至没反映
- google google
- 谁有好看点的 textbox ,label ,button 的CSS 阿?
"' and " + "password='" + password+"'";
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
boolean flag = rs.next();
if (flag == true) {
response.sendRedirect(
"http://localhost/LoginManage/success.html"); } else {
response.sendRedirect(
"http://localhost/LoginManage/nosuccess.html");
}
and + password=‘"+ password“‘;
"' and " + "password='" + password+"'";
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
boolean flag = rs.next();
if (flag == true) {
response.sendRedirect(
"http://localhost/LoginManage/success.html");
return;
} else {
out.println("已经成功登陆");
response.sendRedirect(
"http://localhost/LoginManage/nosuccess.html");
return;
}
正确的方式如下:
String sql = "select * from UserTbl where userName = ? and password=?";
pstmt = con.prepareStatement(sql);
pstmt.setString(1,userName);
pstmt.setString(2,password);
rs = pstmt.executeQuery();
boolean flag = rs.next();
if (flag == true) {
response.sendRedirect("success.html");
//这里还要加上session授权代码,你自己加
} else {
response.sendRedirect("nosuccess.html");
out.println("已经成功登陆");
}