gpt4 book ai didi

arrays - 使用 Thymeleaf 将数组转换为字符串的 null 安全方法是什么

转载 作者:行者123 更新时间:2023-12-02 01:47:28 25 4
gpt4 key购买 nike

我正在尝试使用 Thymeleaf 将字符串数组转换为字符串。

th:value="${#strings.arrayJoin(result.param.searchCondition.mstoneIds, ',')}"

问题是,如果我的数组为空,我会得到一个异常。是否有任何 null 安全方法将数组转换为字符串?谢谢。

最佳答案

你可以像这样进行条件检查

th:value="${result.param.searchCondition.mstoneIds != null} ? ${#strings.arrayJoin(result.param.searchCondition.mstoneIds, ',')} : 'null value'"

关于arrays - 使用 Thymeleaf 将数组转换为字符串的 null 安全方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39218966/

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