![](/img/trans.png)
[英]How to send Mono of ResponseEntity of a class which has Flux/Mono attribute
[英]How right to send Flux or Mono to template (Freemaker)
我从我的存储库 Flux 中获得,在我的 controller 中,我想将它发送到我的模板。 我的 controller:
@GetMapping("users")
public String getAllUser(Model model){
Flux<User> all = userRepo.findAll();
model.addAttribute("user", all);
return "mainpage";
}
我的 Freemarker 模板出现错误:
${user.content} оr ${user}
reemarker.core.InvalidReferenceException:以下已评估为 null 或缺失:==> 用户
问题是,您需要在 Java 中调用什么来获取user
的content
? 当您在模板中编写user.content
时,FreeMarker 会使用默认配置尝试user.getContent()
和user.get("content")
。 但这可以通过Configuration.setObjectWrapper
进行定制。 您可以扩展DefaultObjectWrapper
以便它知道Flux
API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.