I\'m writing a short web form application using spring boot and thymeleaf on IntelliJ, but it seems that in the html file, all fields in the model cannot be resolved. Here is my
I want to add one more thing. As stated above, the issue has been fixed in IntelliJ 2017.3. I can also confirm this.
However, I noticed that this is only true if you define all your attributes directly inside the responsible controller function, like e.g. this:
@RequestMapping(value = "/userinput")
public String showUserForm(Model model){
model.addAttribute("method", "post");
model.addAttribute("user", new User());
return "userform";
}
If you are using a sub-function in which you define the model attributes (see Example below), IntelliJ can still not find the attributes in the HTML template.
Example:
@RequestMapping(value = "/userinput")
public String showUserForm(Model model){
return doIt(model);
}
private String doIt(Model model) {
model.addAttribute("method", "post");
model.addAttribute("user", new User());
return "userform";
}
So, always make sure you put your code directly inside the view function!