select前台转义后台取到的值为对应的文本 select同时接受list和map

简单描述:select动态取值 要求是根据后台传过来的值在前台进行转义,emmm干就完了

思路分析:后台同时传过去一个map一个list ,map用来前台转义,list用来获取值,list取到的值相当于map的key

代码:

//后台java代码
HashMap<String, String> serviceMap = new HashMap<>();
serviceMap.put("1", "仅保存");
serviceMap.put("2", "已发布");
serviceMap.put("3", "已删除"); modelMap.addAttribute("serviceMap", serviceMap); modelMap.addAttribute("list",list); return VIEW_PATH + "/list";

//html代码
<tr th:each="list : ${list}">
<td>
<label class="mt-checkbox mt-checkbox-single mt-checkbox-outline">
<input type="checkbox" class="checkboxes" th:value="${list.serviceId}"/>
</label>
</td>
<td th:text="${list.serviceName}">服务名称</td>
<td th:text="${list.serviceCode}">服务编码</td>
<td th:text="${serviceMap['__${list.serviceType}__']}">服务类型</td>
</tr>
//说明一下: 最后一个td 中的${list.serviceType}取出来的值是1 2 3,serviceMap会把list取出来的1 2 3当做key来取值 仅保存 已发布 已删除

 

转载于:https://www.cnblogs.com/xuchao0506/p/9779533.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值