Load freemarker template from classpath and filesystem in Spring
In Spring can we load freemarker template in both filesystem and classpath?? All of the pages of web application we put in jar bundle, Spring will lookup in filesystem first if not found then it will search in classpath, whenever we want to override some page we just create a开发者_Python百科 new one in some folder of web application that we specified at config. With this approach my web application can hot detection without stop server.
You can use your ApplicationContext instance to find resources using getResource and use them:
ApplicationContext context = //load your app context
Resource resource = context.getResource("relative/file/path.fmk");
if ( !resource.exists() ) {
resource = context.getResource("classpath:inside/your/classpath/path.fmk");
}
// do whatever you would like to do with this resource
精彩评论