如何将Thymelaf动态创建的guid与Thymelav中的guid列表进行比较



我在listOfShortlistedProfile中有一个guid列表作为[cc0dfb4d-4b08-4f08-a8ce-10f12f860ed5, c6bc6a26-a9e0-4ca0-855a-2eeff3922998, a5b3b65b-76c5-446f-a083-4707ac3080d7],在thymelaf中有一一个动态guid${searchResult.guid}作为一个值作为c6bc6a26-a9e0-4ca0-855a-2eeff3922998,我想检查这个动态guid是否包含guid列表。因此,我在Thymelaf中的代码类似于<span th:text="${#lists.contains(listOfShortlistedProfile,'${searchResult.GUUID}')}"></span>,甚至我也尝试过使用<span th:text="${#lists.contains(listOfShortlistedProfile,${searchResult.GUUID})}"></span>但始终会出现错误org.springframework.expression.spel.SpelParseException: Expression [#lists.contains(listOfShortlistedProfile,${searchResult.GUUID})] @42: EL1043E: Unexpected token. Expected 'rparen())' but was 'lcurly({)'

所以,请确认,我如何使用这个运行时guid在Thymelaf的列表中包含内容。

不需要searchResult部分周围的花括号,因为您已经在表达式中了。这就是错误的含义。

正确的代码应该是这样的:

<span th:text="${#lists.contains(listOfShortlistedProfile,searchResult.GUUID)}"></span>

最新更新