@Controller
public class MainController {
@Value("${upload.path}")
private String filePath;
public List<String> showFiles(String path){
File dir = new File(path); //path указывает на директорию
List<String> lst = new ArrayList<>();
for ( File file : dir.listFiles() ){
if (file.isFile()) {
lst.add(file.getName());
}
}
return lst;
}
@GetMapping("/main")
public String getUsers(Model model) throws IOException {
Iterable<String> files = showFiles(filePath);
model.addAttribute("files", files);
return "main";
}
}