代碼寫成我這種程度真是不容易,趕緊去燒燒香!!
1.首先出現的錯誤就是把jar包導入項目後,servlet始終處于報錯的狀态,index.jsp壓根就死在了那裡,出不來。
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
java.lang.ClassNotFoundException: org.apache.jsp.index_jsp java.net.URLClassLoader$1.run(Unknown Source) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(Unknown Source) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134) org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66) org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:618) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
問題分析:可能你的項目中含有過時的servlet-api.jar或者jsp.jar包,趕緊尋找下删掉,否則會和tomcat的jar包沖突,我删掉之後還是不行,依然是這麼報錯,此時發現,我的myeclipse自動導入的jar中少了兩個關鍵的jar包,鄙視之,就是jstl.jar和standard.jar這兩個jar包,導入後,發現出錯界面變了~!!變成了。。。
java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor
好吧,繼續解決。
Tomcat中catalina.jar和jasper.jar都有AnnotationProcessor接口,是以運作時,就出錯了:java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor。
異常的解決方法:
找到你的tomcat安裝路徑,C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf下面有個
context.xml檔案,在其中添加<Loader delegate="true" />即可。
啊,和藹可親的index.jsp頁面出來鳥!!