【问题标题】:I want to abbreviate a string with Thymeleaf我想用 Thymeleaf 缩写一个字符串
【发布时间】:2018-04-18 10:32:13
【问题描述】:

我有一个表,我想更改一个列,该列包含一个字符串。例如:“这是我的字符串”-->“这是我的……”。我尝试使用 abbreviate() 来做到这一点。

<td th:text="${#strings.abbreviate( ${fgp.explanation}, 10)}"></td>

但我收到此错误:EL1043E: Unexpected token。预期 'rparen())' 但 是'lcurly({)'。 S{fgp.explanation} 包含字符串

【问题讨论】:

    标签: java spring thymeleaf


    【解决方案1】:

    您的语法需要更正。

    一般情况是:${#strings.abbreviate(str,10)} 所以你会想要:

    &lt;td th:text="${#strings.abbreviate(fgp.explanation, 10)}"&gt;[this is my...]&lt;/td&gt;

    【讨论】:

    • 太棒了!我觉得在这些情况下,错误消息可以改进。
    猜你喜欢
    • 2021-11-09
    • 1970-01-01
    • 2013-07-05
    • 1970-01-01
    • 2020-08-31
    • 2016-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多