I am trying to configure spring boot thymeleaf and intellij, and for the most part have nailed it, but I cant seem to be able to link controllers with their views, as intellij annoyingly keeps displaying the following message, and the auto-completing the system is not working:
Cannot Resolve 'varName'
my controller looks like this "main/java/..../controller.java"
@Controller
public class CardsController {
@RequestMapping(value="/card/{id}",method = RequestMethod.GET)
public String viewCardAction(@PathVariable("id") Card card,Model model){
model.addAttribute("card",card);
return "cards/view";
}
}
And this is my mockup view "main/resources/cards/view/cards/view":
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<meta charset="UTF-8"/>
<title th:text="${card.name}"></title> <!-- this line shows the message -->
</head>
<body>
<div th:text="${card.name}"></div> <!-- this line shows the message -->
</body>
</html>
is it that intelij, is still not working for this, or am I missing some configuration
NOTE: it works and compiles, just wanna enable autocomplete
First thing first, you need to bind your modelattribute to a th:object in your form as this: ModelAttribute("personList") then in your form your have this th:object="${personList}". Number 2: You will need a name attribute on your form in other to let thymeleaf bind your form input to your object attributes.
The ViewResolver interface in Spring MVC maps the view names returned by a controller to actual view objects. ThymeleafViewResolver implements the ViewResolver interface, and it's used to determine which Thymeleaf views to render, given a view name.
Thymeleaf offers a set of Spring integrations that allow you to use it as a fully-featured substitute for JSP in Spring MVC applications.
Looks like this is a bug in Intellij.
Here's the youtrack link: https://youtrack.jetbrains.com/issue/IDEA-132738
It hasn't gotten much attention from the JetBrains developers yet so you may want to add your comments or vote it up there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With