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

开发者社区> 问答> 正文

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

2016-03-23 15:07:15 3698 1

一下是我的代码

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)
取消 提交回答
全部回答(1)
  • 海贼王fans
    2019-07-17 19:11:12

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

    0 0
相关问答

1

回答

如何卸载容器服务K8s集群中Java应用的Agent?

2022-03-17 01:06:34 367浏览量 回答数 1

1

回答

Java Web层框架支持哪种类型的页面修饰/组成机制?

2021-10-30 23:40:05 103浏览量 回答数 1

1

回答

如何卸载容器服务 K8s 集群中 Java 应用的探针?

2020-03-28 20:17:29 532浏览量 回答数 1

1

回答

java web 三大组件

2019-12-12 15:44:58 199浏览量 回答数 1

3

回答

[@倚贤][¥20]做Java web前端什么框架比较好上手?重点考虑浏览器兼容性问题?

2018-10-30 23:57:56 1951浏览量 回答数 3

1

回答

javaweb服务是什么意思

2018-05-10 20:08:55 1217浏览量 回答数 1

0

回答

JavaWeb开发三年经验

2016-06-02 11:28:44 1810浏览量 回答数 0

1

回答

请教一个关于java正则表达式的问题

2016-03-12 17:31:17 1870浏览量 回答数 1

2

回答

javaweb项目应该放在ECS 那个文件里面呢

2015-11-14 22:32:14 3489浏览量 回答数 2

1

回答

javaweb工程的移植

2015-07-17 11:04:16 2953浏览量 回答数 1
+关注
2
文章
9426
问答
问答排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载