【发布时间】:2023-03-03 15:37:01
【问题描述】:
我有这样的速度模板:
+-----------------------------------------------------------+-------------+-------------+-------------+-------------+
| $totalPel Pelanggan | $totalBk | $totalAdm | $totalTag | $totalTotal |
+-----------------------------------------------------------+-------------+-------------+-------------+-------------+
当我输入 $totalPel -> 100 时,结果是:
+-----------------------------------------------------------+-------------+-------------+-------------+-------------+
| 100 Pelanggan | $totalBk | $totalAdm | $totalTag | $totalTotal |
+-----------------------------------------------------------+-------------+-------------+-------------+-------------+
其实我想得到这样的结果:
+-----------------------------------------------------------+-------------+-------------+-------------+-------------+
| 100 Pelanggan | $totalBk | $totalAdm | $totalTag | $totalTotal |
+-----------------------------------------------------------+-------------+-------------+-------------+-------------+
谁能教我怎么做?
我使用这个 java 代码:
Velocity.init();
VelocityContext context = new VelocityContext();
context.put("totalPel", 100);
Template template = Velocity.getTemplate("LaporanTagihan.txt");
StringWriter writer = new StringWriter();
template.merge(context, writer);
System.out.println(writer.toString());
【问题讨论】:
-
我真的不明白你在这里想要什么......有什么区别?只是更多的空间?这通常在模板中进行控制。
-
是的,我只想为结果自动添加空间。当我输入很多参数时它很有用:D
标签: java velocity template-engine