Message Java. IO. FileNotFoundException: D: \ apache tomcat - 7.0.100 - Windows - x64 \ apache tomcat -- 7.0.100 \ webapps \ houserent \ upload C: \ \ Users \ m3607 \ Desktop \ \ PIC 03. JPG (filename, directory name, or volume slogan method is not correct,)
Description the server encountered an unexpected situation, prevent it to complete the request,
The Exception
Java. IO. IOException: Java. IO. FileNotFoundException: D: \ apache tomcat - 7.0.100 - Windows - x64 \ apache tomcat - 7.0.100 \ webapps \ houserent \ upload C: \ \ Users \ m3607 \ Desktop \ \ PIC 03. JPG (filename, directory name, or volume slogan method is not correct,)
Xyx. House. Web. HouseAdd. DoPost (HouseAdd. Java: 36)
Javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 647)
Javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 728)
Org, apache tomcat, websocket server. WsFilter. DoFilter (WsFilter. Java: 52)
Xyx. Filter. Encoding. DoFilter (22) Encoding. Java:
Root Cause
Java. IO. FileNotFoundException: D: \ apache tomcat - 7.0.100 - Windows - x64 \ apache tomcat - 7.0.100 \ webapps \ houserent \ upload C: \ \ Users \ m3607 \ Desktop \ \ PIC 03. JPG (filename, directory name, or volume slogan method is not correct,)
Java. IO. FileOutputStream. Open0 (Native Method)
Java. IO. FileOutputStream. Open (FileOutputStream. Java: 270)
Java. IO. FileOutputStream. & lt; init> (FileOutputStream. Java: 213)
Java. IO. FileOutputStream. & lt; init> (FileOutputStream. Java: 162)
Org, apache tomcat. Util. HTTP. Fileupload. Disk. DiskFileItem. Write (DiskFileItem. Java: 400)
Xyx. House. Web. HouseAdd. DoPost (HouseAdd. Java: 36)
Javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 647)
Javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 728)
Org, apache tomcat, websocket server. WsFilter. DoFilter (WsFilter. Java: 52)
Xyx. Filter. Encoding. DoFilter (22) Encoding. Java:
Ackage xyx. House. Web;
import java.io.IOException;
import javax.servlet.ServletException;
The import javax.mail. Servlet. The annotation. MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
The import javax.mail. Servlet. HTTP. Part;
The import xyx. House. Dao. HouseDao;
@ WebServlet ("/HouseAdd. Do ")
@ MultipartConfig
Public class HouseAdd extends the HttpServlet {
HouseDao HouseDao=new HouseDao ();
Protected void doPost (it request, HttpServletResponse response) throws ServletException, IOException {
Request. SetCharacterEncoding (" utf-8 ");
String houseName=request. The getParameter (" houseName ");
String houseAddress=request. The getParameter (" houseAddress ");
String houseMoney=request. The getParameter (" houseMoney ");
String houseArea=request. The getParameter (" houseArea ");
String houseType=request. The getParameter (" houseType ");
String houseLord=request. The getParameter (" houseLord ");
String houseTel=request. The getParameter (" houseTel ");
Part Part=request. GetPart (" houseImage ");
The String header=part. GetHeader (" the Content - Disposition ");
The String fileName=header. The substring (header. IndexOf (" fileName=\ "") + 10,
The header. LastIndexOf (" \ ""));
String path=request. GetServletContext (.) getRealPath ("/upload ");
Enclosing houseDao. HouseAdd (houseName houseAddress, houseMoney, houseArea, houseType, houseLord, houseTel, fileName);
Part. Write (path + "/" + fileName);
Request. GetRequestDispatcher (" success. JSP "). The forward (request, response);
}
Protected void doGet (it request, HttpServletResponse response) throws ServletException, IOException {
The Integer id=Integer. The valueOf (request. The getParameter (" id "));
Try {
This. HouseDao. HouseDelete (id);
} the catch (RuntimeException e) {
Request. SetAttribute (" message ", um participant etMessage ());
}
Request. GetRequestDispatcher (" success. JSP "). The forward (request, response);
}
}
CodePudding user response:
Print the filename filename