String filePath="test.txt" org.springframework.core.io.Resource resource = new ClassPathResource( filePath); File file=resource.getFile();
filePath放在类路径下。也就是工程的src文件夹下面。编译后会到WEB-INF下面的classes文件夹下面。
String filePath="test.txt" org.springframework.core.io.Resource resource = new ClassPathResource( filePath); File file=resource.getFile();