在运行index.jsp
时,它必须通过servlet的方法POST
进行检查,并且任务必须更进一步。但是在我尝试的时候,它并没有做到它应该做的事情。
执行servlet可以执行此任务,但是如果执行index.jsp
它显示error.jsp
输入了错误的凭据,但无法通过POST
方法执行操作。页面渲染回index.jsp
为什么会这样?
的index.jsp
<form method="POST" action="j_security_check">
<table cellpadding="0" cellspasing="0" border="0">
<tr>
<td align="right">Username: </td>
<td>
<input type="text" name="j_username">
</td>
</tr>
<tr>
<td align="right">Password: </td>
<td>
<input type="password" name="j_password">
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Login"</td>
</tr>
</table>
</form>
error.jsp文件
<title>Login Error</title>
</head>
<body>
There was an error logging in. Please try again.
</body>
ControllerServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
response.getWriter().println("Welcome");