Java 我想将图像存储在WebContent\upload\news文件夹中,并将路径保存在eclips中的database.in servlet中

Java 我想将图像存储在WebContent\upload\news文件夹中,并将路径保存在eclips中的database.in servlet中,java,Java,[我的代码是:] 编码: 我使用的代码图像存储在.metadata\.plugins\org.eclipse.wst.server.core\tmp3\wtpwebapps\RealEstate\upload\news中 请建议我如何在WebContent\upload\news文件夹中存储图像 谢谢你 String savePath = getServletContext().getRealPath("/")+"upload/news/"; File fileSaveDir=new Fi

[我的代码是:]


编码:
我使用的代码图像存储在
.metadata\.plugins\org.eclipse.wst.server.core\tmp3\wtpwebapps\RealEstate\upload\news中

请建议我如何在WebContent\upload\news文件夹中存储图像

谢谢你


String savePath = getServletContext().getRealPath("/")+"upload/news/";
File fileSaveDir=new File(savePath); 
if(!fileSaveDir.exists()) {
    fileSaveDir.mkdir();
}
Part part=request.getPart("uploadFile");
String fileName=extractFileName(part);
part.write(savePath+fileName);