webflux/reactive 模板引擎选择 freemarker/thymeleaf

发布于 / 随记 / 0条评论 / Tags: java / 21 次浏览

由于使用新的web框架webflux,来写html页面,虽然thymeleaf据说性能不如freemarker,但是对Reactive支持的好啊。

看下MVC式的调用Reatve渲染

  @GetMapping("/home")
    public String home(final Model model) {

        Flux<Post> postList = this.posts.findAll();
        model.addAttribute("posts", new ReactiveDataDriverContextVariable(postList, 100));
        return "home";
}

所以笔者准备采用thymeleaf作为模板了,谁让他支持Reactive呢,小小的性能损失不算什么,关键性能在数据库访问。样例https://github.com/hantsy/spring-reactive-sample/tree/master/mvc-thymeleaf

    评论区(暂无评论)