private String diskpath;
@RequestMapping(“/”)
public String index(Model m){
File[] files = FileUtil.ls(diskpath);
m.addAttribute(“files”,files);
return “index”;
}
}
加@Data是为了自动生成set方法,这样才能让@ConfigurationProperties(prefix = “root”)自动去读取yml中的数据。
添加一个依赖,至于为什么要添加,这个在SpringBoot教程里面讲过了。
org.springframework.boot
spring-boot-configuration-processor
2.5.1
true
注意版本号得是2.5.1,不写版本号默认去下载2.5.2了,我的idea默认的maven下载不到这个jar,估计是源头仓库就没有。
这个问题让站长纠结了好半天。
index.html
效果:
丑一点没关系,我们先把功能给实现了。
[