gpt4 book ai didi

java - 如果字符串包含 thymeleaf 中的键,如何设置字符串中的值

转载 作者:行者123 更新时间:2023-12-02 01:16:20 24 4
gpt4 key购买 nike

我正在尝试设置字符串中的值,但问题是包含键的同一字符串..

注意:- String 内容将根据用户选择而更改,但 key 不会更改。

    binder.put("ocPercent", "5");
binder.put("ocPercentInWords", "Five");
${ocPercent} % (${ocPercentInWords} Percent) of the principal portion of the Receivables,

List<ParagraphDetails> internalCredit = new ArrayList<>();

//String Content

internalCredit.add("${ocPercent} % (${ocPercentInWords} Percent) of the principal portion of the Receivables ..etc")

binder.put("internalCredit", internalCredit);

HTML

<div th:each="internalCreditEnhancement : ${internalCredit}">               
<p><span th:text="${internalCreditEnhancement.Contents}"></span></p>
</div>

输出到来

${ocPercent} % (${ocPercentInWords} Percent) of the principal portion of the Receivables ..etc

但预期输出应该是

5 % (Five Percent) of the principal portion of the Receivables ..etc

如何实现这个概念?

最佳答案

${ocPercent} % (${ocPercentInWords} Percent) 替换为 ocPercent +"%"("+ocPercentInWords+"Percent)"

您应该使用字符串连接而不是表达式语言。

应在 html 代码中使用表达式。

关于java - 如果字符串包含 thymeleaf 中的键,如何设置字符串中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58481980/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com