I got from my repository Flux and in my controller I want to send it to my template. my controller:
@GetMapping("users")
public String getAllUser(Model model){
Flux<User> all = userRepo.findAll();
model.addAttribute("user", all);
return "mainpage";
}
I getting error in my Freemarker’s template :
${user.content} оr ${user}
reemarker.core.InvalidReferenceException: The following has evaluated to null or missing: ==> user
Advertisement
Answer
Question is, what do you need to call in Java to get the content of the user? When you write user.content in the template, with the default configuration FreeMarker will try things like user.getContent(), and user.get("content"). But this can be customized, with Configuration.setObjectWrapper. You could extend DefaultObjectWrapper so that it’s aware of the Flux API.