单击提交后代码不是 运行,它显示 404。我在桌面上写了类似的代码,它是 运行。谁能帮我吗

The code is not running after clicking on submit it show 404. I wright similer code on my desktop in my desktop it is running. can any one help me out

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form action="/details">
        First name: <input type="text" name="fname"><br> 
        Last name: <input type="text" name="lname"><br>
        <br> <input type="submit" value="Submit">
    </form>
</body>
</html>
@WebServlet("/details")  
public class ShowDetails extends HttpServlet {
    
    /**
     * 
     */
    private static final long serialVersionUID = 7384650098624517113L;

    public void service(HttpServletRequest request, HttpServletResponse response) {
        String fName = request.getParameter("fname");
        String lName = request.getParameter("lname");
        
        System.out.println(fName + " " + lName );
        
    }

}

点击提交后

它必须在控制台上打印值

HTML 页

<form action="/details"> 更改为 <form action="/DemoServlet/details">

由于 servlet 路径是相对于 /DemoServlet 的(您可以在 web.xml 中设置),ShowDetails servlet 将位于 localhost:2222/DemoServlet/details 而不仅仅是 localhost:2222/details.