以另一种方式写前端登陆界面
程序包src写
导入jar包 步骤:file—>project structure—>+寻找路径导入包jsp-api和servlet-api
web.xml
登陆index
成功登录main
登陆失败failur
将“欢迎来到用户管理系统”改为登录失败。
登陆页面LoginServlet
package com.zhongruan.servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class LoginServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username=request.getParameter(“username”);
String password=request.getParameter(“password”);
if(username.equals(“hualili”)&&password.equals(“123”)){
request.getRequestDispatcher(“main.jsp”).forward(request,response);
}else {
request.getRequestDispatcher(“failure.jsp”).forward(request,response);
}
}
}