thymeleaf 字符串判断是否存在

 <img th:if="${#strings.containsIgnoreCase(files.fileName,'xls')}"
      class="image img-rounded" th:height="200" th:width="200"
      th:src="@{/xls.jpg}">
<img th:if="${#strings.containsIgnoreCase(files.fileName,'pdf')}"
     class="image img-rounded" th:height="200" th:width="200"
     th:src="@{/pdf.jpg}">
<img th:if="${#strings.containsIgnoreCase(files.fileName,'doc')}"
     class="image img-rounded" th:height="200" th:width="200"
     th:src="@{/doc.jpg}">
<img th:if="${!#strings.containsIgnoreCase(files.fileName,'doc')&&!#strings.containsIgnoreCase(files.fileName,'xls')&&!#strings.containsIgnoreCase(files.fileName,'pdf')}"
     class="image img-rounded" th:height="200" th:width="200"
     th:src="@{/kbm/avatar/2019-09-25/9df6747293bd2a44f6d087a99a107f87.png}">

参考:https://blog.csdn.net/qq_33535433/article/details/78876693

posted @ 2019-11-18 14:16  刘阿泽  阅读(4587)  评论(0编辑  收藏  举报