thymeleaf 下拉框多选回显(strings)
数据字典中回显,
th:selected="${#strings.contains(A,B)}"
查询A中是否包含B
<select name="scrapReason" multiple class="form-control m-b"
th:with="type=${@dict.getType('subsidy_apply_scrapReason')}" required>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}" th:selected="${#strings.contains(A,B)}">
</option>
</select>
是否包含(分大小写):
<span th:if="${#strings.contains(A,'a')}">包含a</span>
<span th:if="${#strings.contains(B,'b')}">包含b</span>
是否包含(不分大小写)
<span th:if="${#strings.containsIgnoreCase(A,'a')}">包含a</span>
判断是不是为空字符串:
<span th:if="${#strings.isEmpty(name1)}">空的</span>
剩下的基本和JAVA的string方法相似。