本文主要是介绍The method getRealPath(String) from the type ServletRequest is deprecated,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
File tempFile = new File(fileName);// 构造临时对象
// String savePath=tempFile.getName();
// //返回上传文件在客户端的完整路径名称
// request.setAttribute("filename", savePath);
//File file = new File(request.getRealPath("/upload"), //此句报错。
File file = new File(request.getSession().getServletContext().getRealPath("/upload"),//改成这句。就Ok咯
tempFile.getName()); // 获取根目录对应的真实物理路径
这篇关于The method getRealPath(String) from the type ServletRequest is deprecated的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!