Servlets Servlet映射

Servlets Servlet映射,servlets,web.xml,Servlets,Web.xml,我的问题是我将servlet映射到web.xml上。当我向servlet提交信息时,它会给我“Resourcesisnotfound”错误。我怎样才能解决这个问题。谢谢你的回答 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Login Page</title> </head> <body> <form action="Lo

我的问题是我将servlet映射到web.xml上。当我向servlet提交信息时,它会给我“Resourcesisnotfound”错误。我怎样才能解决这个问题。谢谢你的回答

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login Page</title>
</head>
<body>
<form action="Login" method="POST">
UserName:<input type="text" name="user_name">
<BR>
Password:<input type="password" name="password">
<BR>
<input type="submit" value="Gonder">
<BR>
<input type="reset" value="Reset">
</form>

</body>
</html>
WEB XML代码如下所示

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;


public class Login extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private String usr_name;
    private String pass;
    static Logger log=Logger.getLogger(Login.class);






    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("text/html");
        PropertyConfigurator.configure("C:\\Users\\AliArdaOrhan\\workspace2\\QuizProject\\WebContent\\WEB-INF\\log4j.properties");
        usr_name=request.getParameter("user_name");
        pass=request.getParameter("Password");

        try {
            if(Validation.validate(usr_name,pass)){
                RequestDispatcher rs=request.getRequestDispatcher("Welcome");
                rs.forward(request, response);
            }
            else{
                RequestDispatcher rs=request.getRequestDispatcher("login");
                rs.forward(request, response);
            }
        } catch (ClassNotFoundException | SQLException e) {
            log.error("Cannot Validate User Information", e);
        }

    }

}
   <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>QuizProject</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description>Login Page</description>
    <display-name>Login</display-name>
    <servlet-name>Login</servlet-name>
    <servlet-class>Login</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Login</servlet-name>
    <url-pattern>/Login</url-pattern>
  </servlet-mapping>
  <servlet>
    <description></description>
    <display-name>Welcome</display-name>
    <servlet-name>Welcome</servlet-name>
    <servlet-class>Welcome</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Welcome</servlet-name>
    <url-pattern>/Welcome</url-pattern>
  </servlet-mapping>
</web-app>

奎茨基项目
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
登录页面
登录
登录
登录
登录
/登录
欢迎
欢迎
欢迎
欢迎
/欢迎光临

您正在将表单发送到
登录(相对URL),但您的servlet在
/GuestBook
等待。更改servlet映射或表单的操作属性。

请在这一行进行更改

<form action="Login" method="POST">


将“
Login
”替换为“
/GuestBook

您需要在web.xml中为
登录
操作添加servlet映射:

<servlet>
    <description></description>
    <display-name>Login</display-name>
    <servlet-name>Login</servlet-name>
    <servlet-class>Login</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Login</servlet-name>
    <url-pattern>/Login</url-pattern>
</servlet-mapping>

我发布了错误的web.xml文件。我现在改了。好的,我发现了错误。errow is HTML发送“Password”参数,但servlet请求“Password”,所以验证过程不起作用,servlet跳过if块,直接转到else块。在else块中,有一个登录调用,但在我的应用程序中没有任何其他登录servlet。谢谢你的帮助。
@WebServlet("/Login")
public class Login extends HttpServlet {