項目運行一直很平穩,但是換了tomcat之后打開jsp網頁時就報錯,描述如下:
1. 錯誤描述
打開jsp網頁時報錯
java.lang.NullPointerException
org.apache.jsp.WEB_002dINF.pages.imagecheck.test_jsp._jspInit(test_jsp.java:22)
或 java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
2. 原因
由於tomcat 和 項目 中都有 servlet-api.jar 和 jsp-api.jar,換了tomcat之后,tomcat中的jar版本及編譯的jdk版本不同,導致沖突
版本查看,請看下圖

Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.4 Created-By: 1.6.0_45-b06 (Sun Microsystems Inc.) X-Compile-Source-JDK: 1.6 X-Compile-Target-JDK: 1.6 Name: javax/servlet/jsp/ Specification-Title: Java API for JavaServer Pages Specification-Version: 2.2 Specification-Vendor: Sun Microsystems, Inc. Implementation-Title: javax.servlet.jsp Implementation-Version: 2.2.FR Implementation-Vendor: Apache Software Foundation