错误消息
SEVERE: Servlet.service() for servlet [school.EditAssociate] in context with path [/school_attendance] threw exception [Servlet execution threw an exception] with root cause
java.lang.Error: Unresolved compilation problems:
The method getSubmittedFileName() is undefined for the type Part
The method getSubmittedFileName() is undefined for the type Part
web.xml文件
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
attendance.jsp
<td class="text-center">
<label for="ojtupload0" class="custom-file-upload">
<i class="fa fa-cloud-upload"></i>
</label> <input id="ojtupload0" type="file" style="display: none;" /> </td>
<td class="text-center"><label for="testPaperupload0" class="custom-file-upload"><i class="fa fa-cloud-upload"></i></label>
<input id="testPaperupload0" type="file" style="display: none;" /></td>
attendance.java
// obtains the upload file part in this multipart request
Part filePart1 = request.getPart("OJT"+i);
if (filePart1 != null) {
// prints out some information for debugging
System.out.println(filePart1.getName());
System.out.println(filePart1.getSize());
System.out.println(filePart1.getContentType());
filename1 = filePart1.getSubmittedFileName();
filenamecol1 = "OJTFilename";
//inAssTraingStat.setString(1, filenamecol1);
inAssTraingStat.setString(11, filename1);
System.out.println(filenamecol1);
我正在使用Java编译器1.8,Servlet API 3.0,Tomcat 9,MsSql,JSP,JavaScript。 我收到错误消息:当我尝试更新数据或将数据输入到Sql数据库中时,类型Part的方法getSubmittedFileName()未定义。
任何解决问题的想法。从2天开始,以前的代码现在可以正常工作了。