Tag: 速度

如何在不重新启动速度的情况下编辑velocimacro?

我的速度宏正在被缓存,我不希望它们……至少在开发期间不是这样。 我在属性文件中设置了以下属性… velocimacro.library.autoreload=true file.resource.loader.cache=false velocity.engine.resource.manager.cache.enabled=false ……但这似乎并没有成功 使用速度属性,如何配置速度以不缓存宏? (我使用的是速度1.6.4) 编辑: 我不认为这条线…… velocity.engine.resource.manager.cache.enabled=false ……与速度有关

如何在Velocity foreach循环中获得从零开始的计数

我试图在Velocity #foreach指令中获得一个从零开始的计数器。 如果我使用: #foreach ($item in $list) item.getName() : $velocityCount #end 我会得到: Fred : 1 Wilma : 2 Barney : 3 但是我需要: Fred : 0 Wilma : 1 Barney : 2 从速度模板的角度来看,解决方案必须尽可能简单。 编辑 : 我可以用: #foreach ($item in $list) #set( $num = $velocityCount – 1 ) //The white space in mandatory item.getName() : $num #end […]

velocity:除了在最后一次循环迭代中做一些事情

在速度方面,我想在最后一个循环中做一些不同的事情。 什么是正确的习语? 相关 : java中增强for循环的最后一次迭代

速度字符串function

我刚开始使用Java Velocity。 现在我想创建一个java类模板。 package $app.package_namespace public class ${app.name}Station { #foreach($s_attribute in $app.station) $s_attribute.type $s_attribute.name, #end public $app.name Station(#foreach($s_attribute in $app.station) $s_attribute.type $s_attribute.name; #end) { #foreach($s_attribute in $app.station) $s_attribute.name=$s_attribute.name; #end } #foreach($s_attribute in $app.station) public ${s_attribute.type} get${s_attribute.name}() { return get${s_attribute.name}(); } #end } 问题是s_attribute.name第一个字符是小写。 当我为属性创建getter和setter函数时。 我需要将第一个字符更改为大写字母。 有谁知道怎么做?

在速度模板中转义引号

我有一个java方法,需要几个字符串。 需要从Velocity Template调用此方法。 但是,字符串太复杂,有很多单引号,双引号和逗号。 结果合并失败了。 有没有办法逃避Velocity的报价?

我如何通过Velocity修剪空白

我有一个名为render_something的方法,可以创建大量的空格,例如: #render_something(‘xxx’) 结果可能是: something that generate from redner_something 实际上我希望它是这样的: something that generate from redner_something 速度有这样的东西吗? #trim(#render_something(‘xxx’))

Freemarker / Velocity – 日期操作

关于这两个模板引擎,我有一个相当简单的问题。 我正在努力创造一个未来/过去的日期,从现在开始的固定时间,例如18个月前或明天。 我知道可以使用velocity / freemarker模板中的java日期对象(类似于$date.add(2,-18) )来执行此操作,但我想使用DateTool或freemarker core来执行此操作 。 这是我认为纯粹的表现forms(只是在你在飞行预订表格中看到的默认日期),所以我看不出为什么模板引擎不能做到这一点。 虽然可以吗? 如果是这样,怎么样?

Velocity nulls和空字符串

在速度我有一个变量,其值为null 。 在这种情况下我不想显示任何内容。 目前模板引擎将“”转换为null,所以我必须这样做。 #set ( $a = “”) #if ($a) assert(“never prints a neither gets here: ” + $a) #end 有没有办法直接做到这一点? 我希望能够做出像: This is the variable $a. ## in case that $a is null i don’t want ‘dollar a’ to be displayed

从速度视图页面内调用类方法(静态)

你能从视图页面内调用类方法吗? 特别是未传递到视图中的那些? 在asp.net MVC中,我可以这样做:

Velocity无法找到资源

出了点问题,非常令人沮丧。 我在velocity的主页上读到,当我运行webapp时,应该设置一些属性。 我已经做到了,但无论我做什么,我都会遇到同样的错误。 这是我设置道具和使用速度的地方 public class ConfirmationMailGenerator implements MailGenerator { private BasicUser user; private String htmlTemplate = “HTMLConfirmationMailTemplate.vsl”; private String plainTemplate = “PlainConfirmationMailTemplate.vsl”; public ConfirmationMailGenerator(BasicUser user) { this.user = user; } public StringWriter generateHTML() throws Exception { Properties props = new Properties(); props.setProperty(“resource.loader”, “wepapp”); props.setProperty(“webapp.resource.loader.class”, “org.apache.velocity.tools.view.WebappResourceLoader”); props.setProperty(“webapp.resource.loader.path”, “/WEB-INF/mailtemplates/”); VelocityEngine engine = new VelocityEngine(props); VelocityContext context […]