Thymeleaf in IntelliJ: cannot resolve variables
I've been ignoring that issue for as long as I've been using Thymeleaf. Even though it shows the squiggly lines, it should still work when you run the application.
IntelliJ would almost have to compile the code in the background to be able to automatically (and accurately, since you could have multiple methods who uses the same template) resolve the variables.
I've never given a tip like this, but after reading your comment that you just find the wiggly line annoying, I decided to suggest it anyways:
Disable the tip.
I feel absolutely barbaric for posting this answer, forgive me SO
For recent versions of IntelliJ:
With the cursor on the variable, press Alt-Enter and you should see a menu option to "Declare external variable in comment annotation". When you select this option, you'll get a comment template with the cursor positioned to type in the data type of the variable.
When complete, you'll have something that looks like this:
<!--/*@thymesVar id="productIds" type="java.util.Map"*/-->
<div data-th-each="p : ${productIds}">
The Alt-enter menu doesn't seem to work within expressions such as ${#maps.isEmpty(productIds)}
. In this case, manually creating the comment might make the UI get rid of the "unresolved" indicator.