获取webapp下的img路径

使用ApplicationHome 获取当前文件的路径 ,ApplicationHome只能在springboot工程中使用
// 上传地址
ApplicationHome applicationHome = new ApplicationHome(ImageUtils.class);
String path = applicationHome.getSource().getParentFile().getParentFile().getParentFile().getPath()
+ "\\SuperMarket-web\\src\\main\\webapp\\img";
该博客介绍了如何在SpringBoot应用中使用ApplicationHome获取当前类的路径,并以此确定webapp下img目录的绝对路径,为文件上传提供路径参考。
6058

被折叠的 条评论
为什么被折叠?



