首先创建一个新的项目,命名为servletjsp,然后导包,建文件夹
创建登录界面
然后设置登录界面
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);
}
}
}
配置web