当我尝试使用初始化速度引擎时
VelocityEngine engine = new VelocityEngine();
engine.init();
Run Code Online (Sandbox Code Playgroud)
我尝试时遇到同样的错误
Velocity.init();
Run Code Online (Sandbox Code Playgroud)
org.apache.velocity.exception.VelocityException:无法使用当前运行时配置初始化org.apache.velocity.runtime.log.ServletLogChute的实例.
什么可能导致这个例外?
use*_*127 10
尝试这样的事情:
Properties p = new Properties();
p.setProperty("resource.loader", "class");
p.setProperty("class.resource.loader.description", "Velocity Classpath Resource Loader");
p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
try {
Velocity.init(p);
} catch(...., and handle excpetion
}
Run Code Online (Sandbox Code Playgroud)
你现在可以打电话:
VelocityContext vContext = new VelocityContext(context);
//put things into vContext
StringWriter sw = new StringWriter();
try {
template.merge(vContext, sw);
Run Code Online (Sandbox Code Playgroud)
等等
| 归档时间: |
|
| 查看次数: |
19869 次 |
| 最近记录: |