首页 > 其他分享 >Spring boot 的路径踩坑

Spring boot 的路径踩坑

时间:2022-12-28 15:56:05浏览次数:51  
标签:Spring 路径 boot add getPath FileSystems getDefault list path

 

代码

    @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

相关文章