代码
@ApiOperation(value = "测试") @PostMapping("/GetFileSystem") public List<String> getFileSystem(HttpServletRequest request){ List<String> list=new ArrayList<>(); String path="UploadFiles"; list.add("FileSystems.getDefault():"+FileSystems.getDefault()); list.add("FileSystems.getDefault().getPath(path):"+FileSystems.getDefault().getPath(path)); list.add("FileSystems.getDefault().getPath(path).getParent():"+FileSystems.getDefault().getPath(path).getParent()); list.add("getRealPath:"+request.getSession().getServletContext().getRealPath(path)); list.add("getContextPath:"+request.getSession().getServletContext().getContextPath()); return list; }
结果
[ "FileSystems.getDefault():sun.nio.fs.WindowsFileSystem@7ebb201c", "FileSystems.getDefault().getPath(path):UploadFiles", "FileSystems.getDefault().getPath(path).getParent():null", "getRealPath:D:\\apache-tomcat-9.0.68\\webapps\\tly-file\\UploadFiles", "getContextPath:/tly-file" ]
标签:Spring,路径,boot,add,getPath,FileSystems,getDefault,list,path From: https://www.cnblogs.com/cvol/p/16976006.html