zoukankan      html  css  js  c++  java
  • thymeleaf入门和学习

      springboot框架不推荐使用jsp,一方面是兼容性的技术问题,一方面也是其前后端整合在一起,很难适合当下大规模的网站开发环境。HTML只是一种标记语言,并不具有获取model中数据的功能,所以视图解析得用一种新的框架,比如thymeleaf,js等。

      那么thymeleaf怎么获取session的信息呢?参考这篇文章:https://www.cnblogs.com/LinKinSJ/p/9592447.html

      下面看一下它的配置代码,具体语法可以参看这篇文章,https://www.cnblogs.com/itdragon/archive/2018/04/13/8724291.html

    package org.springframework.boot.autoconfigure.thymeleaf; import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider; import org.springframework.core.env.Environment; import org.springframework.core.io.ResourceLoader; import org.springframework.util.ClassUtils; // Environment类型能干什么和,以及为什么在properties文件中可以通过spring.thymeleaf.suffix可以改变其路径 public class ThymeleafTemplateAvailabilityProvider implements TemplateAvailabilityProvider { @Override public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) { if (ClassUtils.isPresent("org.thymeleaf.spring5.SpringTemplateEngine", classLoader)) { String prefix = environment.getProperty("spring.thymeleaf.prefix", ThymeleafProperties.DEFAULT_PREFIX); String suffix = environment.getProperty("spring.thymeleaf.suffix", ThymeleafProperties.DEFAULT_SUFFIX); return resourceLoader.getResource(prefix + view + suffix).exists(); } return false; } }

  • 相关阅读:
    Webpack 学习笔记总结
    Ctrl+C和Ctrl+V无法使用
    mysql默认字符集问题
    Makefile 简述
    Shell编程学习之重定向
    Shell编程学习之Shell编程基础(一)
    Linux系统目录
    关于Linux部分版本无法安装Chrome的问题
    整数算术溢出问题的分析
    Linux中的/etc/nologin问题
  • 原文地址:https://www.cnblogs.com/Robin008/p/10212939.html
Copyright © 2011-2022 走看看