本文整理了Java中org.apache.velocity.app.Velocity.addProperty()
方法的一些代码示例,展示了Velocity.addProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Velocity.addProperty()
方法的具体详情如下:
包路径:org.apache.velocity.app.Velocity
类名称:Velocity
方法名:addProperty
[英]Add a Velocity Runtime property.
[中]添加Velocity运行时属性。
代码示例来源:origin: com.legsem.legstar/legstar-codegen
/**
* Setup Velocity so that it searches for templates in the classpath.
* <p/>
* In order to work around issue 158 that arises when velocity dynamically
* loaded classes are already in the context classloader parent, we
* temporarily switch to a new context classloader that sees our plugin
* classes and dependencies only.
*
* @throws CodeGenVelocityException if setup fails
*/
public static void initVelocity() throws CodeGenVelocityException {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Velocity.addProperty("resource.loader", "classpath");
Velocity.addProperty("classpath.resource.loader.description",
"Velocity Classpath Resource Loader");
Velocity.addProperty("classpath.resource.loader.class",
"org.apache.velocity.runtime.resource.loader."
+ "ClasspathResourceLoader");
Velocity.addProperty("classpath.resource.loader.cache", true);
Thread.currentThread().setContextClassLoader(
Velocity.class.getClassLoader());
Velocity.init();
} catch (Exception e) {
throw new CodeGenVelocityException(e);
} finally {
Thread.currentThread().setContextClassLoader(loader);
}
}
代码示例来源:origin: velocity/velocity-dep
/**
* Default constructor.
*/
MultipleFileResourcePathTest()
{
super("MultipleFileResourcePathTest");
try
{
assureResultsDirectoryExists(RESULTS_DIR);
Velocity.addProperty(
Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH1);
Velocity.addProperty(
Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH2);
Velocity.init();
}
catch (Exception e)
{
System.err.println("Cannot setup MultipleFileResourcePathTest!");
e.printStackTrace();
System.exit(1);
}
}
代码示例来源:origin: baiczsy/evergreenframework
/**
* 初始化Velocity
* @throws IOException
*/
private static void initVelocity() throws IOException {
InputStream in = VelocityTemplate.class.getClassLoader().getResourceAsStream("velocity.properties");
Properties prop = new Properties();
prop.load(in);
for (String name : prop.stringPropertyNames()) {
if(name.equals(Velocity.FILE_RESOURCE_LOADER_PATH)){
String projectDir = ActionContext.getContext().getRealPath("");
Velocity.addProperty(name, projectDir + prop.getProperty(name));
} else {
Velocity.addProperty(name, prop.getProperty(name));
}
}
Velocity.init();
}
}
代码示例来源:origin: org.w3c.css/css-validator
path = new URI(path).getPath();
Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path + "../css/");
Velocity.setProperty(Velocity.RUNTIME_LOG,
"velocity-" + new SimpleDateFormat("yyyy-MM-dd_HHmm").format(new Date()) + ".log");
代码示例来源:origin: velocity/velocity-dep
Velocity.addProperty(
"classpath." + Velocity.RESOURCE_LOADER + ".class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
代码示例来源:origin: org.w3c.css/css-validator
Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path + "../../../../");
Velocity.setProperty(Velocity.RUNTIME_LOG,
"velocity-" + new SimpleDateFormat("yyyy-MM-dd_HHmm").format(new Date()) + ".log");
代码示例来源:origin: velocity/velocity-dep
Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
Velocity.addProperty(Velocity.RESOURCE_LOADER, "classpath");
Velocity.addProperty(Velocity.RESOURCE_LOADER, "jar");
内容来源于网络,如有侵权,请联系作者删除!