LoginServlet页面404
@WebServlet(name="LoginServlet", urlPatterns={"/LoginServlet"}) public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public LoginServlet() { } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doPost"); String username = request.getParameter("username"); String password = request.getParameter("password"); System.out.println(request.getContextPath()); if("admin".equals(username) && "admin".equals(password)) { //校验通过 HttpSession session = request.getSession(); session.setAttribute("username", username); System.out.println(request.getContextPath()); response.sendRedirect(request.getContextPath()+ "/success.jsp"); }else { //校验失败 response.sendRedirect(request.getContextPath()+ "/failure.jsp"); } } }
这是LoginServlet.java的代码,输入用户名密码后跳转页面出错,404
<body> <form action="<%=request.getContextPath() %>/servlet/LoginServlet" method="post"> 用户名:<input type="text" name="username" /> 密码:<input type="password" name="password" /> <input type="submit" value="提交" /> </form> </body>
上面这是login.jsp的代码
输入用户名密码登录以后,显示页面为:
HTTP Status 404 - /LoginFilter/servlet/LoginServlet type Status report message /LoginFilter/servlet/LoginServlet description The requested resource is not available.