Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to compare thymeleaf dynamically created guid with list of guid in Thymeleaf

I have a list of guid in listOfShortlistedProfile as [cc0dfb4d-4b08-4f08-a8ce-10f12f860ed5, c6bc6a26-a9e0-4ca0-855a-2eeff3922998, a5b3b65b-76c5-446f-a083-4707ac3080d7] and I have a dynamic guid as ${searchResult.GUUID} as one value as c6bc6a26-a9e0-4ca0-855a-2eeff3922998 in thymeleaf and I want to check if this dynamic guid contains from list of guid. So, my code in Thymeleaf is like <span th:text="${#lists.contains(listOfShortlistedProfile,'${searchResult.GUUID}')}"></span> even I also tried with <span th:text="${#lists.contains(listOfShortlistedProfile,${searchResult.GUUID})}"></span> but all times it gives error as
org.springframework.expression.spel.SpelParseException: Expression [#lists.contains(listOfShortlistedProfile,${searchResult.GUUID})] @42: EL1043E: Unexpected token. Expected 'rparen())' but was 'lcurly({)'

So, please confirm, how do I use contains in list in Thymeleaf with this runtime guid.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The curly brackets around the searchResult part are not needed because you are already in an expression. This is what the error signifies.

The correct code should look like this:

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading