【问题标题】:Displaying Thymeleaf model list with conditions显示带条件的 Thymeleaf 模型列表
【发布时间】:2018-10-31 05:14:46
【问题描述】:

我想显示模型属性列表。但是我收到了类似的错误

org.thymeleaf.exceptions.TemplateProcessingException:无法解析为表达式:"(${storeInfo.storeStatus} == 'InActive')? (color:red):(color:black)""

下面是代码,请帮忙

<select id="storeDropDown" th:field="*{storeId}" name="storeId" class="form-control input-md mb-md">
<option value="NA" th:name="stareStatus" th:text="#{reports.selectStore}"> 
</option>
<option th:each="storeInfo : ${storeInfoList}"  th:value="${storeInfo.storeId}"  th:style="(${storeInfo.storeStatus} == 'InActive'||'Active')? (color:red):(color:black)" th:text="${storeInfo.storeName}" th:name="${storeInfo.storeStatus}"></option>

【问题讨论】:

    标签: html thymeleaf


    【解决方案1】:

    你的表达对我来说没有意义(你有额外的括号、引号,并试图 OR 一个布尔值和一个字符串)。如果我不得不猜测,也许是这个?

    th:style="${storeInfo.storeStatus == 'InActive' ? 'color: red;' : 'color: black;'}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-16
      • 2018-01-24
      • 1970-01-01
      • 2013-08-27
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多