thymeleaf字符串和数值的大小比较
场景:下拉框默认选中 失效,代码如下:
<option th:each="brand : ${brands}" th:text="${brand.name}" th:value="${brand.id}" th:selected="${brand.id == category.content}"></option>
后来将值打印出来 发现 selected都是false,就发现是表达式的问题
brand.id 是数值 category.content 是个字符串
解决办法: 表达式如下:
${brand.id+’’ ==category.content}