javaweb servlet 404 萌新求助!

我分别加了两个servlet到web.xml,图片说明

但是只有一个能成功访问,照着网上再重新配置tomcat,build automatically啥的,都没用,o(╥﹏╥)o
图片说明
图片说明

明明是类似的,为什么另一个就不行啊
我在servlet.java文件里面print了一下,信息都是可以出来的,控制台除了print出来的信息其他也没报错
然后下面这个是报错的servlet代码

package com.lms.servlet;

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

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

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import com.lms.domain.User;
import com.lms.utils.jdbcUtils;

/**
 * Servlet implementation class signupServlet
 */
public class signupServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
     */
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        //获取请求参数
        String workerid = request.getParameter("workeridsignup");
        String password = request.getParameter("passwordsignup");
        String phonenumber = request.getParameter("phonenumbersignup");
        String message="";
        System.out.println(workerid + password + phonenumber);
//         if(workerid.equals("")){
//             message="用户名不能为空";
//             request.setAttribute("message", message);
//             request.getRequestDispatcher("/index.jsp").forward(request, response);
//         }else{
               //使用dbutils连接到数据库
               QueryRunner qr = new QueryRunner(jdbcUtils.getDataSource());
               //String sql = "select * from user where workerid=? and password=?";
               String sql = "insert into user (workerid, password, phonenumber) values ("+workerid+","+password+","+phonenumber+");";
               System.out.println(sql);

               try {
                   qr.execute(sql, new BeanHandler<User>(User.class));
                   System.out.println("executing");
                   //qr.query(sql, new BeanHandler<User>(User.class));
                   //user = qr.query(sql, new BeanHandler<User>(User.class), workerid,password);
                   } catch (SQLException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
                     }

               request.setAttribute("message", message);
               request.getRequestDispatcher("/login.jsp").forward(request, response);
          // }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        //response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

1个回答

看看你的JAVA代码

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!