WebApplicationContext获取项目的文件
org.springframework.web.context.WebApplicationContext; 可以获取web项目的文件
private WebApplicationContext springCtx;
/**
* 获取文件
*
* @param location
* @return
*/
public File getFile(String location) {
try {
Resource res = springCtx.getResource(location);
return res.getFile();
} catch (Exception e) {
e.printStackTrace();
throw new AresRuntimeException("common.system_error", e);
}
} public void init(ContextLoader contextLoader) {
springCtx = ContextLoader.getCurrentWebApplicationContext();
}
