0

我有JoinCustomerToAccountServletservlet src/controller-

@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 。

4

1 回答 1

2

因为您的 URL 映射是/JoinCustomerToAccountServlet并且因为您的 JSP 位于内部/MyBankProject/ActionsPages,所以您必须将表单的操作更改为:

<form action="../JoinCustomerToAccountServlet"让它工作。

于 2012-08-10T10:34:08.933 回答