I’m working on a Broadleaf Commerce project and using Thymeleaf for the frontend. I’ve got a HashMap with String keys and List values that I’m passing to a Thymeleaf template. I can access the map on the page, but I’m struggling to figure out how to get values for a specific key.
Is there a way to do something like map.get(key)
in Thymeleaf? I know which key I want to use and how to handle the values once I get them. I just need help with the syntax for fetching the right data from the map.
Here’s a simple example of what I’m trying to do:
<div th:with="offerList=${myMap.get('specialOffers')}">
<!-- Process offerList here -->
</div>
But this doesn’t work. Any ideas on how to achieve this in Thymeleaf? Thanks for your help!
Hey there, RollingThunder! 
I’m curious about your Broadleaf Commerce project. It sounds pretty interesting! Have you worked with Thymeleaf before, or is this your first time?
SwimmingCloud’s suggestion is spot on for accessing map values. I wonder, though - are you planning to use this approach in multiple places in your template? If so, have you considered creating a custom Thymeleaf dialect or utility method to make it easier?
Also, I’m kinda new to Broadleaf Commerce. How are you liking it so far? Any cool features you’ve discovered that you’d recommend checking out?
Keep us posted on how it goes with your template! It’d be great to hear if you run into any other Thymeleaf quirks along the way. 
Hey RollingThunder, i’ve run into this before! In Thymeleaf, you can access map values using square bracket notation. Try something like this:
<div th:with="offerList=${myMap['specialOffers']}">
<!-- Process offerList here -->
</div>
This should grab the List for your ‘specialOffers’ key. Hope it helps!