问题描述
错误:cn.com.jbaptech.javaoraprj.faqtool.CommandException:AddCommand:NoDriverAvailable!cn.com.jbaptech.javaoraprj.faqtool.AddCommand.execute(AddCommand.java:35)cn.com.jbaptech.javaoraprj.faqtool.FaqAdminServlet.service(FaqAdminServlet.java:25)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
解决方案
解决方案二:
javax.servlet.http.HttpServlet在servlet-api.jar
解决方案三:
servlet-api.jar
解决方案四:
那怎样将它导入到工程里面?我用的是myeclipse
解决方案五:
这是运行环境中的包,不需要导入到classpath中的。
解决方案六:
那我这是什么错啊错误:atcn.com.jbaptech.javaoraprj.faqtool.AddCommand.execute(AddCommand.java:35)atcn.com.jbaptech.javaoraprj.faqtool.FaqAdminServlet.service(FaqAdminServlet.java:25)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:717)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)atjava.lang.Thread.run(UnknownSource)AddCommand.java代码:packagecn.com.jbaptech.javaoraprj.faqtool;importjavax.servlet.*;importjavax.servlet.http.*;publicclassAddCommandimplementsCommand{privateStringnext;publicAddCommand(Stringnext){this.next=next;}publicStringexecute(HttpServletRequestreq)throwsCommandException{try{if(CommandToken.isValid(req)){FaqRepositoryfaqs=FaqRepository.getInstance();FaqBeanfaq=newFaqBean();faq.setQuestion(req.getParameter("question"));faq.setAnswer(req.getParameter("answer"));faqs.put(faq);req.setAttribute("faqtool.msg","FAQAddedSuccessfully");}else{req.setAttribute("faqtool.msg","InvalidReloadAttempted");}returnnext;}catch(FaqRepositoryExceptionfe){thrownewCommandException("AddCommand:"+fe.getMessage());}}}FaqAdminServlet.java代码:packagecn.com.jbaptech.javaoraprj.faqtool;importjava.io.*;importjavax.servlet.*;importjavax.servlet.http.*;importjavax.servlet.http.HttpServlet.*;importjava.util.*;publicclassFaqAdminServletextendsHttpServlet{privateHashMapcommands;privateStringerror="error.jsp";privateStringjspdir="/faqtool/";publicvoidinit(ServletConfigconfig)throwsServletException{super.init(config);initCommands();}publicvoidservice(HttpServletRequestreq,HttpServletResponseres)throwsServletException,IOException{Stringnext;try{Commandcmd=lookupCommand(req.getParameter("cmd"));next=cmd.execute(req);CommandToken.set(req);}catch(CommandExceptione){req.setAttribute("javax.servlet.jsp.jspException",e);next=error;}RequestDispatcherrd;rd=getServletContext().getRequestDispatcher(jspdir+next);rd.forward(req,res);}privateCommandlookupCommand(Stringcmd)throwsCommandException{if(cmd==null)cmd="main-menu";if(commands.containsKey(cmd.toLowerCase()))return(Command)commands.get(cmd.toLowerCase());elsethrownewCommandException("InvalidCommandIdentifier");}privatevoidinitCommands(){commands=newHashMap();commands.put("main-menu",newNullCommand("menu.jsp"));commands.put("abort",newAbortCommand("menu.jsp"));commands.put("add",newNullCommand("add.jsp"));commands.put("do-add",newAddCommand("menu.jsp"));commands.put("update-menu",newGetAllCommand("upd_menu.jsp"));commands.put("update",newGetCommand("update.jsp"));commands.put("do-update",newUpdateCommand("menu.jsp"));commands.put("delete-menu",newGetAllCommand("del_menu.jsp"));commands.put("delete",newGetCommand("delete.jsp"));commands.put("do-delete",newDeleteCommand("menu.jsp"));}}求救!!!!!!!!!!!!!
解决方案七:
还有个错误:cn.com.jbaptech.javaoraprj.faqtool.CommandException:AddCommand:NoDriverAvailable!
解决方案八:
这个方法的错35行错了publicStringexecute(HttpServletRequestreq)throwsCommandException{try{if(CommandToken.isValid(req)){FaqRepositoryfaqs=FaqRepository.getInstance();FaqBeanfaq=newFaqBean();faq.setQuestion(req.getParameter("question"));faq.setAnswer(req.getParameter("answer"));faqs.put(faq);req.setAttribute("faqtool.msg","FAQAddedSuccessfully");}else{req.setAttribute("faqtool.msg","InvalidReloadAttempted");}returnnext;}catch(FaqRepositoryExceptionfe){thrownewCommandException("AddCommand:"+fe.getMessage());}}}
解决方案九:
驱动有问题引用6楼fengyu12345的回复:
还有个错误:cn.com.jbaptech.javaoraprj.faqtool.CommandException:AddCommand:NoDriverAvailable!
解决方案十:
我已经被这个问题困扰两天了,大侠们帮帮忙!!!!
解决方案十一:
我这好像没有35行啊,怎么会错呢?如果是驱动问题,那我跑其他代码的怎么没问题
解决方案十二:
就这个方法错了你自己找找吧publicStringexecute(HttpServletRequestreq)throwsCommandException{异常信息写的啊没有有效的驱动
解决方案十三:
还是谢谢你啊
解决方案十四:
很少用MyEclipse,一般都tomcat+Eclipse,那个jar在tomcat下就有,看看你的部署环境吧
解决方案十五:
我这是不是缺少什么包啊
解决方案:
tomcat要部署环境吗?我以前还都没部署过
解决方案:
没servlet-API.jar
解决方案:
servlet-api.jar包要自己导入吗
解决方案:
可以把你TOMCAT解压开的common/lib目录下的servlet-APIjar复制到项目里
解决方案:
那要复制到哪个目录下呢
解决方案:
项目的WEB-INF/lib下
解决方案:
servlet-api.ja
解决方案:
我怀疑你建的是web项目不?