我想从服务器端加载速度模板,如下所示:
try{
Template template = Velocity.getTemplate("common/pageNav.vm", "GBK");
Writer writer = new StringWriter();
VelocityContext vContext = new VelocityContext(context);
template.merge(vContext, writer);
return writer.toString();
} catch (Exception ex) {
ex.printStackTrace();
// throw new Exception(ex);
return "";
}
但它抛出一个异常
Unable to find resource 'common/pageNav.vm'
在tomcat中运行时如何获取字符串。