学生党,在做期末的课程设计
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
execute(req, resp);
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
execute(req, resp);
}
public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getParameter("ID").equals("admin") && request.getParameter("password").equals("admin")){
request.getRequestDispatcher("../administrator.jsp").forward(request,response);
}else {
StudentAccount account = new StudentAccount();
AdminDAO adminDAO = new AdminDAO();
account.setID(Integer.valueOf(request.getParameter("ID")));
account.setPassword(request.getParameter("password"));
StudentAccount stu = adminDAO.findStuByID(account.getID());
PrintWriter writer = response.getWriter();
if (stu == null) {
writer.print("<script language='javascript'>" +
"alert('The account does not exist!');" +
"window.location.href='../index.jsp';" +
"</script>");
} else {
if (account.getID() == stu.getID() && account.getPassword().equals(stu.getPassword())){
request.getRequestDispatcher("../studentInfo.jsp").forward(request, response);
}else {
writer.print("<script language='javascript'>" +
"alert('Wrong password!');" +
"window.location.href='../index.jsp';" +
"</script>");
}
}
}
}
这是我的LoginServlet,用于登录,然后奇怪的是,假如是登录到administrator.jsp页面的话是正常的,但是跳转到studentInfo页面上,原页面上的中文就直接乱码了,
然后就是直接进入那个页面的话,中文就是没有乱码的
萌新求解