gpt4 book ai didi

java - 无法从jsp页面形式调用servlet

转载 作者:行者123 更新时间:2023-12-02 07:38:21 30 4
gpt4 key购买 nike

我在 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"使其发挥作用。

关于java - 无法从jsp页面形式调用servlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11899840/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com