Java 无法在JSP中的按钮提交操作上加载servlet

Java 无法在JSP中的按钮提交操作上加载servlet,java,forms,jsp,servlets,Java,Forms,Jsp,Servlets,我有一个简单的login.jsp页面,如下所示: <form class="form-horizontal" role="form" action="/SchoolERP/Login" method="post"> <div class="form-group"> <label for="username" class="control-label col-sm-1">Username:</label> &l

我有一个简单的
login.jsp
页面,如下所示:

<form class="form-horizontal" role="form" action="/SchoolERP/Login" method="post">
    <div class="form-group">
        <label for="username" class="control-label col-sm-1">Username:</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="username" placeholder="Username">
        </div>
    </div>
    <div class="form-group">
        <label for="password" class="control-label col-sm-1">Password:</label>
        <div class="col-sm-5">
            <input type="password" class="form-control" id="password" placeholder="Password">
        </div>
    </div>
    <div class="col-sm-offset-1 col-sm-5">
        <button type="submit" class="btn btn-default">Submit</button>
    </div>
</form>
其中
ControllerLogin.java
如下所示:

public class ControllerLogin extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        RequestDispatcher rd = request.getRequestDispatcher("jsp/template.jsp");
        request.setAttribute("content_page", "admin/login.jsp");
        request.setAttribute("title", "Login");
        rd.forward(request, response);
    }

}
当我单击Login.jsp页面上的submit按钮时,它给出的错误是
请求的资源/SchoolERP/Login not found
。我哪里做错了


我在Login.jsp中尝试了各种变体,如
action=“Login”
。同样在
web.xml
中,我尝试使用
Login
/SchoolERP/Login
等,但仍然存在错误。

最终解决了它。我从
web.xml
中删除了
Login
定义,并将注释添加到
ControllerLogin
servlet中,作为
@WebServlet({/Login})
。这起作用了。但我仍然无法理解上面的代码哪里出错了

public class ControllerLogin extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        RequestDispatcher rd = request.getRequestDispatcher("jsp/template.jsp");
        request.setAttribute("content_page", "admin/login.jsp");
        request.setAttribute("title", "Login");
        rd.forward(request, response);
    }

}