08-02-2023, 04:15 PM
I had the same problem and fixed it (ultimate 2021.3.2).
Intellij has a hard time guessing the type of the attribute(s).
Keep **www** in the namespace xmlns:th="http://www.thymeleaf.org" otherwise Intellij won't parse thymeleaf tags
If you initialize one model in a controler,
- don't use a method's return, declare a variable
String titre=post.getTitle();
model.addAttribute("title",titre);
- don't add attributes through sub methods, keep it in the main block
@GetMapping("/book")
public String ver(Model model) {
...
model.addAttribute("title", title);
return "frontpage";
}
- and don't use complex operator like the ternary one
model.addAttribute("titles", titles.size() > 0 ? titles : null);
If you initialize 2 or 3 models in you controler,
don't push null values
model.addAttribute("employees", null);
Intellij has a hard time guessing the type of the attribute(s).
Keep **www** in the namespace xmlns:th="http://www.thymeleaf.org" otherwise Intellij won't parse thymeleaf tags
If you initialize one model in a controler,
- don't use a method's return, declare a variable
String titre=post.getTitle();
model.addAttribute("title",titre);
- don't add attributes through sub methods, keep it in the main block
@GetMapping("/book")
public String ver(Model model) {
...
model.addAttribute("title", title);
return "frontpage";
}
- and don't use complex operator like the ternary one
model.addAttribute("titles", titles.size() > 0 ? titles : null);
If you initialize 2 or 3 models in you controler,
don't push null values
model.addAttribute("employees", null);