簡體   English   中英

無法從jsp頁面表單調用servlet

[英]can't call servlet from jsp page form

我在src/controller下有JoinCustomerToAccountServlet servlet -

@WebServlet("/JoinCustomerToAccountServlet")
public class JoinCustomerToAccountServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {


    }

}

並在WebContent/ActionsPages下形成joinCustomerToAccount.jsp -

<%@ 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"使它工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM