我的输入类型是
<input type="file" id="photo" name="sid" required>
我使用
获取值String img=request.getParameter("sid");
我使用
存储它 String name=request.getParameter("name");
String lname=request.getParameter("lname");
String sapid=request.getParameter("sapid");
String email=request.getParameter("email");
String ph=request.getParameter("pn");
String gender=request.getParameter("gender");
String img=request.getParameter("sid");
String dob=request.getParameter("dob");
File imgfile = new File(img);
FileInputStream fin = new FileInputStream(imgfile);
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
Date date = formatter.parse(dob);
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
ps = c.prepareStatement("insert into personal_details values(?,?,?,?,?,?,?,?)");
ps.setLong(1,Long.parseLong(sapid));
ps.setString(2,name);
ps.setString(3,lname);
ps.setString(4,email);
ps.setLong(5,Long.parseLong(ph));
ps.setString(6,gender);
ps.setDate(7,sqlDate);
ps.setBinaryStream(8,fin,(int)imgfile.length());
ps.executeUpdate();
但是当我执行它时,我给了我一个错误
java.io.IOException: An exception occurred processing
[/registerstudent.jsp] at line [40]
37: String img=request.getParameter("sid");
38: String dob=request.getParameter("dob");
39: File imgfile = new File(img);
40: FileInputStream fin = new FileInputStream(imgfile);
41: SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); 42: Date date = formatter.parse(dob);
43: java.sql.Date sqlDate = new java.sql.Date(date.getTime()); java.io.FileNotFoundException:
Capture3.PNG (The system cannot find the file specified)
java.io.FileInputStream.open0(Native Method)
java.io.FileInputStream.open(FileInputStream.java:195)
java.io.FileInputStream.<init>(FileInputStream.java:138)
org.apache.jsp.registerstudent_jsp._jspService(registerstudent_jsp.java:155)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
我选择一个文件并单击“提交”按钮。但是点击浏览器会显示上面提到的消息。浏览器找不到指定的文件