用Spring类读XML等文件

String filePath="test.txt"
org.springframework.core.io.Resource resource = new ClassPathResource(
				filePath);
File  file=resource.getFile();

filePath放在类路径下。也就是工程的src文件夹下面。编译后会到WEB-INF下面的classes文件夹下面。

猜你喜欢

转载自chen040341.iteye.com/blog/1129047