扑__饭4014296
2018-03-25 21:55
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path; String username = " "; String password = " "; //request.setCharacterEncoding("uft-8");//防止中文乱码 username = request.getParameter("usename");//得到用户名 password = request.getParameter("password"); //如果用户和密码都等于admin则登陆成功 (没用数据库) if("admin".equals(username) && "admin".equals(password)){ session.setAttribute("loginUser", username);//把用户名放到回话 request.getRequestDispatcher("login_success.jsp").forward(request,response); //服务器内部转发 }else{ response.sendRedirect("login_failure.jsp"); //请求重定向 } %>
你的utf-8写成了uft-8,所以不能使用啊!
最好先试一下打印出request.getParameter(
"usename"
)和
request.getParameter(
"password"
)是否为空
JAVA遇见HTML——JSP篇
248277 学习 · 3071 问题
相似问题