参考:cThymeleaf手动渲染_org.thymeleaf.spring5.view.thymeleafviewresolver-优快云博客
对页面进行缓存时第一次手动渲染:
spring4
import org.thymeleaf.spring4.context.SpringWebContext;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
SpringWebContext springWebContext=new SpringWebContext(request,response,request.getServletContext(),request.getLocale(),model.asMap(), applicationContext);
html= thymeleafViewResolver.getTemplateEngine().process("goodsList",springWebContext);
spring5:
import org.thymeleaf.context.WebContext;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
WebContext webContext=new WebContext(request,response,request.getServletContext(),request.getLocale(),model.asMap());
html= thymeleafViewResolver.getTemplateEngine().process("goodsList",webContext);
本文介绍了如何在Spring4和Spring5中使用Thymeleaf进行页面手动渲染,包括SpringWebContext和WebContext的创建以及ThymeleafViewResolver的使用,重点在于首次渲染和可能的缓存策略。
1256

被折叠的 条评论
为什么被折叠?



