急啊 大神帮帮忙看看这是怎么个意思?

未见森林 未见森林 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

这是loginbean的代码
package com.bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import com.util.*;

public class LoginBean {
Connection conn = null;
Statement st = null;
ResultSet rs = null;
ArrayList al = new ArrayList();

public int login(String name,String pwd){
int temp = 0;
conn = DBConn.getConn();
try {
st = conn.createStatement();
rs = st.executeQuery("select * from login where username='"+name+"'");
if(rs.next()){
String username = rs.getString("username");
String userpwd = rs.getString("mima");
String quanxian = rs.getString("quanxian");
if(pwd.equals(userpwd)){
temp = 1;
al.add(username);
al.add(userpwd);
al.add(quanxian);
}else{
temp = 2;
}
}else{
temp = 3;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
DBConn.close(conn,st,rs);
}
return temp;
}

public ArrayList getArrayLst(){
return al;
}

}


这是LoginServlet的代码
package com.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bean.LoginBean;

public class LoginServlet extends HttpServlet {

/**
* Constructor of the object.
*/
public LoginServlet() {
super();
}

/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String name = request.getParameter("username");
String pwd = request.getParameter("userpwd");
String admin = request.getParameter("admin");
String xuesheng = request.getParameter("xuesheng");
String laoshi = request.getParameter("laoshi");
String str = "";
LoginBean lb = new LoginBean();
int flag = lb.login(name,pwd);
if(flag == 2 || flag == 3){
if(admin != null && admin.equals("1")){
str = "jsp/login/adminLogin.jsp";
request.setAttribute("admin","1");
}
if(xuesheng != null && xuesheng.equals("1")){
str = "jsp/login/xueshengLogin.jsp";
request.setAttribute("xuesheng","1");
}
if(laoshi != null && laoshi.equals("1")){
str = "jsp/login/laoshiLogin.jsp";
request.setAttribute("laoshi","1");
}
}
if(flag == 1){ //登录成功
if(admin != null && admin.equals("1")){
str = "jsp/login/adminWelcomLogin.jsp";
}
if(xuesheng != null && xuesheng.equals("1")){
str = "jsp/login/xueshengWelcomLogin.jsp";
}
if(laoshi != null && laoshi.equals("1")){
str = "jsp/login/jiaoshiWelcomLogin.jsp";
}
ArrayList al = lb.getArrayLst();
HttpSession session = request.getSession();
session.setAttribute("login",al);
}
RequestDispatcher rd=request.getRequestDispatcher(str);
rd.forward(request,response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}

/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}

}
在TOMCAT启动后能进入主页面 但是一登录或者注册都是这个页面,有人说是数据库的原因,请各位大神看看这是不是数据库的原因,要不是怎么改这个代码啊。我看上面的提示是这两段代码有问题
...全文
评论 10
收藏 已收藏
分享
返回顶部
未见森林
Web 开发 81,108 成员 341,721 内容