[英]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.