@Value("file:" + "${d:/my/dir/}")
private Resource dir;
如何获取该资源目录中的文件数量?不幸的是,Resource
接口(interface)不提供任何 getFiles() 方法...
最佳答案
基于this version Resource接口(interface)的,可以调用getFile
File theDir = dir.getFile();
if (theDir.isDirectory()) {
theDir.list();
}
如果您将其与 propertyplaceholderconfigurer 结合起来您可能会得到您正在寻找的东西:
关于java - spring中如何获取目录中的资源数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28042284/