This commit is contained in:
Looly 2022-08-30 11:38:42 +08:00
parent c58418017e
commit f4fc7793eb

View File

@ -9,7 +9,7 @@ import org.apache.velocity.app.Velocity;
/**
* Velocity模板引擎<br>
* http://velocity.apache.org/
* <a href="http://velocity.apache.org/">http://velocity.apache.org</a>
*
* @author looly
*/
@ -121,8 +121,6 @@ public class VelocityEngine implements TemplateEngine {
// loader
switch (config.getResourceMode()) {
case CLASSPATH:
// 新版Velocity弃用
// ve.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
ve.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
break;
case FILE:
@ -133,13 +131,13 @@ public class VelocityEngine implements TemplateEngine {
}
break;
case WEB_ROOT:
ve.setProperty(Velocity.RESOURCE_LOADER, "webapp");
ve.setProperty(Velocity.RESOURCE_LOADERS, "webapp");
ve.setProperty("webapp.resource.loader.class", "org.apache.velocity.tools.view.servlet.WebappLoader");
ve.setProperty("webapp.resource.loader.path", ObjUtil.defaultIfNull(config.getPath(), StrUtil.SLASH));
break;
case STRING:
ve.setProperty(Velocity.RESOURCE_LOADER, "str");
ve.setProperty("str.resource.loader.class", SimpleStringResourceLoader.class.getName());
ve.setProperty(Velocity.RESOURCE_LOADERS, "str");
ve.setProperty("resource.loader.str.class", SimpleStringResourceLoader.class.getName());
break;
default:
break;