用servlet实现文件上传报错java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getPart

综合来看,是你j2ee容器(也许是tomcat)自带的api规范不是3.0的,或者tomcat版本过低,并没实现3.0规范导致。看下tomcat自带lib下的servlert-api.jar 这个包的版本。


打开tomcat的lib 目录下,有两个JAR文件: jsp-api.jar servlet-api.jar 。如果没有,那可能是你没有添加进来。解压这两个文件,用记事本分别打开META-INF下的MAINMEFT.MF文件。


JSP的版本信息:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.0
Created-By: 1.6.0_27-b07 (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


Servlet版本:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.0
Created-By: 1.6.0_27-b07 (Sun Microsystems Inc.)
X-Compile-Source-JDK: 1.6
X-Compile-Target-JDK: 1.6


Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 3.0  /*这就是版本号*/
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 3.0.FR
Implementation-Vendor: Apache Software Foundation


你可能感兴趣的:(tomcat,J2EE,jsp-api版本怎么看,getPart报错)