模板模型异常: ?left_pad(...) 参数 #2 不能是长度为 0 的字符串



请帮助解决此错误。这是从Freemarker模板中抛出的。这是StackTrace。。。。

----
FTL stack trace ("~" means nesting-related):
- Failed at: ${t.file_sequence_number?left_pad(6, ...  [in template "abcdTemplate.ftlh" in macro "FRFC10" at line 13, column 122]
- Reached through: @FRFC10  [in template "abcdTemplate.ftlh" at line 31, column 1]
Caused by: freemarker.core._TemplateModelException: ?left_pad(...) argument #2 can't be a 0-length string. 
----

错误消息表示您使用两个参数调用了left_pad内建函数,而第二个参数是空字符串。

第二个参数指定哪个字符串用于填充而不是空格字符。

使用left_pad的正确方法应该是:

|${"a"?left_pad(10)}|
|${"a"?left_pad(10, "*")}|

输出

|         a|
|*********a|

最新更新