gpt4 book ai didi

java - 单选按钮标签更改

转载 作者:太空宇宙 更新时间:2023-11-04 10:40:07 25 4
gpt4 key购买 nike

我需要将单选按钮标签从实际值更改为另一个值

<li th:each="radioValueType: ${type}"><input type="radio"
th:field="*{heads[0].type}" th:value="${radioValueType}" />
<label th:text="${radioValueType}"></label></li>

下面是我的模型属性

    @ModelAttribute("type")
public ArrayList<Integer> getType(){
ArrayList <Integer> type = new ArrayList<Integer>();
type.add(1);
type.add(5);
return type;
}

但是当我需要显示它时,我需要将 1 表示为“单个”,将 5 表示为“团体”。我对 thymeleaf 完全陌生

最佳答案

终于在3个小时后找到了解决方案,下面是代码

<li th:each="radioValueType: ${type}"><input type="radio"
th:field="*{heads[0].type}" th:value="${radioValueType}" />
<label th:text="( (${radioValueType} == 1)? 'Single' : 'Group')"></label></li>

如果有人遇到同样的麻烦

关于java - 单选按钮标签更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49083066/

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