注册Servlet类未找到异常

时间:2015-07-21 06:26:21

标签: jsp servlets jdbc

以下是servlet和web.xml文件。

Register.java

package org.maximo.aadi;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class Register extends HttpServlet {

private static final long serialVersionUID = 1L;

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

        String regno = request.getParameter("rno_input");
        String userdept = request.getParameter("userdept_input");
        String vehicletype = request.getParameter("vehicle_type_input");
        try{

        //loading drivers for mysql
        Class.forName("com.mysql.jdbc.Driver");

        //creating connection with the database 
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/vehicleRH","root","adi.12345");

        PreparedStatement ps = con.prepareStatement("insert into  'vehicleRH'.'checklist'(Registeration,VehicleType,UserDept)values(regno,userdept,vehicletype");

        ps.setString(1, regno);
        ps.setString(2, userdept);
        ps.setString(3, vehicletype);
        int i=ps.executeUpdate();

          if(i>0)
          {
            out.println("You are sucessfully registered");
          }

        }
        catch(Exception se)
        {
            se.printStackTrace();
        }

      }
  }

的web.xml

<?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_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Maximo</display-name>
<servlet>
    <servlet-name>Register</servlet-name>
    <servlet-class>org.maximo.aadi.Register</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Register</servlet-name>
    <url-pattern>/Register</url-pattern>
</servlet-mapping>
<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>
</web-app>
  

.class文件没有生成,可能是什么错误?

我是新手,所以你能告诉我我的代码中有什么错误吗?在运行寄存器类时遇到错误,因为它会给出错误ClassNotFound。任何帮助都会受到赞赏。

0 个答案:

没有答案