java.lang.ClassNotFoundException但库存在

时间:2018-04-14 11:01:39

标签: java

我创建了一个非常有效的类JDBC。但是,当我尝试在另一个类(Authentification)中使用该类时,我有以下错误:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

import com.mysql.jdbc.Driver;
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;



@WebServlet("/AuthServlet")
public class AuthServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        /*
         * The visitor has filled in the index.jsp form which contains the username and
         * the password Let's retrieve those data
         */
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println("Class AuthServlet :\t Username : " + username + " | Password :" + password);

        // checking the data from the form
        Authentification auth = new Authentification(username, password);
        if (auth.isAccessGranted()) {
            RequestDispatcher dispatcher = request.getRequestDispatcher("welcome.jsp");
            dispatcher.forward(request, response);
        } else {
            RequestDispatcher dispatcher = request.getRequestDispatcher("error.jsp");
            dispatcher.forward(request, response);
        }

    }
}

我不明白为什么在我的servlet上看不到JAR。 谢谢!

0 个答案:

没有答案