tomcat服务器未加载web.xml it';s运行jsp';它不是servlet

tomcat服务器未加载web.xml it';s运行jsp';它不是servlet,jsp,tomcat,servlets,web.xml,Jsp,Tomcat,Servlets,Web.xml,我已经通过cpanel在运行Tomcat7.0的实时服务器上部署了Java Web应用程序,它可以很好地处理.jsp页面。似乎它没有加载web.xml文件,所以它没有映射servlet 我已经在本地服务器上对我的应用程序进行了全面测试。 下面是Web.xml文件 <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"

我已经通过cpanel在运行Tomcat7.0的实时服务器上部署了Java Web应用程序,它可以很好地处理.jsp页面。似乎它没有加载web.xml文件,所以它没有映射servlet

我已经在本地服务器上对我的应用程序进行了全面测试。 下面是Web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>



     <servlet>
        <servlet-name>ProcessLogin</servlet-name>
        <servlet-class>authentication.ProcessLogin</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ProcessLogin</servlet-name>
        <url-pattern>/Welcome</url-pattern>
    </servlet-mapping>

</web-app>

我花了十几个小时搜索这个问题,但找不到解决方案。

web.xml正在正确加载,因为执行了JSP文件。您不需要在web.xml中声明servlet,因为您正在使用注释并在web.xml中声明servlet 3.0,您会遇到什么错误?提交时,浏览器URL中的上下文路径是否更改?示例:>?是的,在localhost中,它工作正常,contextPath更改,但在Onlinet中不起作用。请看一看:上下文路径仍在更改,但它找不到文件。
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login Here</title>
        <link rel="stylesheet" type="text/css" href="main.css">
    </head>
    <body>

        <div class="header">
           ...
        </div>
        <div class="container" style="height:85%">
            <div class="contents"> 

                   <form name="form1" id="form1" method="post"  action="Welcome" >
                    User Name: <input type="text" name="txtName" id="txtName" required  class="txtfield"> <br />
                    Password:<input type="password" size="50" name="txtPass" required  class="txtfield" /> <br />
                        <input type="submit" value="Sign In" /> 

                    </form>


            </div>
        </div> 
        <div class="footer">
            ....
        </div>  
    </body>
</html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Student Management</title>
        <link rel="stylesheet" type="text/css" href="main.css">
        <script src="library/jquery-1.9.1.js"></script>
    </head>
    <body>


        <div class="container"  style="height:84%">

            <div class="contents" style="margin:0 auto; width:650px">
                Welcome dear:
            </div>

        </div>
        <div class="footer">
            ...
        </div>
    </body>
</html>
package authentication;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import utilities.User;


@WebServlet(name = "ProcessLogin", urlPatterns = {"/Welcome"})
public class ProcessLogin extends HttpServlet {


    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {

            User user = new User();
            String userName = request.getParameter("txtName");
            String password = request.getParameter("txtPass");
            boolean isUser = user.checkUser(userName,password);


                if (isUser) {
                        HttpSession session = request.getSession();
                        session.setAttribute("userId", userName);

                        RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
                        rd.forward(request, response);

                } else {
                    response.sendRedirect("login.jsp?err=1");
                }


        } finally {
            out.close();
        }

    }


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


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



}