一个关于Javaweb网页跳转的问题-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

一个关于Javaweb网页跳转的问题

爵霸 2016-03-23 15:07:15 2228

一下是我的代码

Insert.java

 
package com.Servlet;
 
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import com.bean.SqlBean;
import com.bean.JavaBean;
 
public class Insert extends HttpServlet {
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    /**
     * The doDelete method of the servlet. <br>
     *
     * This method is called when a HTTP delete request is received.
     * 
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doDelete(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
 
        // Put your code here
    }
 
    /**
     * The doGet method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to get.
     * 
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
 
        response.setContentType("text/html");
           doPost(request,response);
         
    }
 
    /**
     * The doPost method of the servlet. <br>
     *
     * This method is called when a form has its tag value method equals to post.
     * 
     * @param request the request send by the client to the server
     * @param response the response send by the server to the client
     * @throws ServletException if an error occurred
     * @throws IOException if an error occurred
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
 
        response.setContentType("text/html");
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        //获取前台页面数据
        String name =request.getParameter("name");
        String password =request.getParameter("password");
        String sex =request.getParameter("sex");
        String sage = request.getParameter("age");
        int age  =Integer.parseInt(sage);
         
        //封装到JavaBean对象中去
        JavaBean jBean = new JavaBean();
         
        jBean.setName(name);
        jBean.setPassword(password);
        jBean.setSex(sex);
        jBean.setAge(age);
         
        //调用模型层
        String sql = "insert into TestNXSC(Name,Password,Sex,Age) values(?,?,?,?)";
        SqlBean  sBean = new SqlBean();
        int count =sBean.getInsert(sql,jBean);
        String url="";
        if(count>0)
        {
            url="SearchList.jsp";
        }
        else
        {
            url ="error.jsp";
            request.setAttribute("error", "ע��");
        }
        //转发ת
        request.getRequestDispatcher("SearchList.jsp").forward(request, response);
    }
}
 

报错



exception

javax.servlet.ServletException: Error instantiating servlet class com.servlet.Insert
   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
   org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
   org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
   org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
   org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
   org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
   java.lang.Thread.run(Thread.java:745)
root cause

java.lang.ClassNotFoundException: com.servlet.Insert
   org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1308)
   org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1142)
   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
   org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
   org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
   org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
   org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
   org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
   java.lang.Thread.run(Thread.java:745)
SQL Python
分享到
取消 提交回答
全部回答(1)
  • 海贼王fans
    2019-07-17 19:11:12

    大小写问题:报错显示 com.servlet.Insert 你的代码显示 package com.Servlet;
    如果用windows修改过包名,则svn提交时不会大小写敏感

    0 0
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题