日期:2014-05-18  浏览次数:20831 次

用Jsp+servlet+javaben插入mysql成功,为什么还显示数据格式转换错误呢?
我用myeclipse进行开发,数据库用的是mysql,先定义了一个javabean-Bbsuser,

这个bean里定义了数据库中用户表的相关字段,我把用于登录和注册都写在了同一个

页面

里,可是注册时一点提交,就显示如下错误:

严重:   Servlet.service()   for   servlet   jsp   threw   exception
java.lang.ClassCastException:   bbs.Bbsuser
at   org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:63)
at   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at   org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at   org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at   org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at   bbs.BbsloginServlet.forward(BbsloginServlet.java:115)
at   bbs.BbsloginServlet.user_add(BbsloginServlet.java:100)
at   bbs.BbsloginServlet.doGet(BbsloginServlet.java:31)
at   bbs.BbsloginServlet.doPost(BbsloginServlet.java:14)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at   bbs.EncodingFilter.doFilter(EncodingFilter.java:46)
at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at   org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:831)
at   org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
at   org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1203)
at   java.lang.Thread.run(Thread.java:595)
org.apache.jasper.JasperException:   bbs.Bbsuser
at   org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510