我在JoinCustomerToAccountServlet
下有src/controller
servlet-
@WebServlet("/JoinCustomerToAccountServlet")
public class JoinCustomerToAccountServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
}
然后在
joinCustomerToAccount.jsp
下形成WebContent/ActionsPages
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
</head>
<body>
<form action="JoinCustomerToAccountServlet" method="POST">
Account join to him : <input type="text" name="account" />
<input type="submit" value="join" />
</body>
</html>
填写表格并按提交按钮后,我得到
type Status report
message /MyBankProject/ActionsPages/JoinCustomerToAccountServlet
description The requested resource (/MyBankProject/ActionsPages/JoinCustomerToAccountServlet) is not available.
它看起来像在他的文件夹下搜索表单,而不是在搜索servlet。
最佳答案
由于您的URL映射是/JoinCustomerToAccountServlet
,并且JSP驻留在/MyBankProject/ActionsPages
中,因此您必须将表单的操作更改为:<form action="../JoinCustomerToAccountServlet"
使其起作用。