1. 配置pom

    1. 如果是2.x的直接配置一个starter即可

        <!-- ThymeLeaf 依赖 -->
      <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>
    2. 如果是1.x的 还需要配置一些参数

        <!-- 布局功能的支持程序  thymeleaf3主程序  layout2以上版本 -->
      <thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
      <thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
  2. resoruces下面建立 templates文件夹

  3. 把html文件放在templates里面,以.html结尾,可以在html里面加入命名声明

    1. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  4. 编写controller类,用@Controller 不要用@RestController!如果前后端分离不是很彻底的项目,建议在controllr包 分为API和view包。分别放纯接口返回一个放模板访问的

    @Controller //注意  不要用 RestController
    public class Say {
    @RequestMapping("hi")
    public String hi() {
    return "/list"; //需要加入”/“, 反而RequestMapping里面如果是直接访问反而不需要"/”
    }
    }

      

  5. 配置application.yml文件(非强制)
    spring:
    thymeleaf:
    mode: HTML
    encoding: UTF-8
    servlet:
    content-type: text/html
    prefix: classpath:/templates
    suffix: .html
    cache: false

      

@Controller //注意 这个地方 不要用 RestController
public class Say {
   @RequestMapping("hi")
   public String hi() {
       return "/list"; //这里需要加入”/“, 反而RequestMapping里面如果是直接访问反而不需要"/”
  }
}

 

Loading definitions...

爱词霸

 

 
划词翻译
自动发声
自动添加生词本

spring boot2.3.0集成 thymelaf的更多相关文章

  1. spring boot 2.0 集成 shiro 和 pac4j cas单点登录

    新开的项目,果断使用  spring boot  最新版本  2.0.3 ,免得后期升级坑太多,前期把雷先排了. 由于对 shiro 比较熟,故使用 shiro 来做权限控制.同时已经存在了 cas  ...

  2. spring boot2.x中集成H2数据库

    H2数据库介绍  查看 在spring boot中集成 1.添加依赖 <dependency> <groupId>org.springframework.boot</gr ...

  3. Spring Boot 2.0 集成 Druid 数据源

    一.Maven项目依赖 <!-- 开发者工具(热部署 修改classpath下的文件springboot自动重启) --> <dependency> <groupId&g ...

  4. spring boot2 运行环境

    1.springboot个版本系统需求 spring boot maven jdk 内置tomcat 内置jetty servlet 2.0.x 3.2+ 8或9 8.5(3.1) 9.4(3.1) ...

  5. 【spring cloud】spring cloud2.X spring boot2.0.4调用feign配置Hystrix Dashboard 和 集成Turbine 【解决:Hystrix仪表盘Unable to connect to Command Metric Stream】【解决:Hystrix仪表盘Loading...】

    环境: <java.version>1.8</java.version><spring-boot.version>2.0.4.RELEASE</spring- ...

  6. Spring Boot2.0使用Spring Security

     一.Spring Secutity简介     Spring 是一个非常流行和成功的 Java 应用开发框架.Spring Security 基于 Spring 框架,提供了一套 Web 应用安全性 ...

  7. spring boot 2.0(一)权威发布spring boot2.0

    Spring Boot2.0.0.RELEASE正式发布,在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误,然后Spring ...

  8. Spring Boot2.0之整合事物管理

    首先Spring 事务分类 1.声明事务  原理:基于编程事务的 2.编程事务  指定范围 扫包去解决 3.事务原理:AOP技术   通过环绕通知进行了拦截 使用Spring 事务注意事项: 不要tr ...

  9. 基于spring boot2.0+spring security +oauth2.0+ jwt微服务架构

    github地址:https://github.com/hankuikuide/microservice-spring-security-oauth2 项目介绍 该项目是一个演示项目,主要演示了,基于 ...

  10. SpringBoot之整合Quartz调度框架-基于Spring Boot2.0.2版本

    1.项目基础 项目是基于Spring Boot2.x版本的 2.添加依赖 <!-- quartz依赖 --> <dependency> <groupId>org.s ...

随机推荐

  1. PyTorch Geometric(pyg)学习

    参考2个链接: 第十六课.Pytorch-geometric入门(一)_tzc_fly的博客-CSDN博客_pytorch-geometric 第十七课.Pytorch-geometric入门(二)_ ...

  2. Java基础——IO设计模式总结

  3. input放入焦点,选中全部文本

    async mounted(){ let inputList = document.querySelectorAll('input'); for (let index = 0; index < ...

  4. MyBatis(Plus) 打印SQL, 分析执行时间

    MyBatis/MyBatis Plus打印的SQL调试起来比较麻烦 当然IDEA/eclipse都有类似mybatis log plugin这种插件来解析, 但是安装插件有些许弊端, 就写了个工具类 ...

  5. zookeeper(1)-集群的搭建

    集群搭建 1. 下载二进制文件 $ wget --no-check-certificate https://mirrors.ustc.edu.cn/apache/zookeeper/zookeeper ...

  6. wpf 自定义Messagebox时,对话框显示不居中问题

    在自定义Messagebox(有属性Window.SizeToContent="WidthAndHeight")时,对话框显示不居中,经过尝试,应设置如下: msgBox.Wind ...

  7. HIVE - HIVEQL学习笔记

    Hive Learning HIVEQL和MYSQL最为接近 数据操作 SHOW TABLES IN crm_integration Show tables 'dim_con*' DESCRIBE E ...

  8. jar打包exe选型

    网上一搜有篇文章写了9中不同工具方法,最后使用launch4j,其实就一点开源免费. launch4j>bsd3协议(可免费商用),像exe4j需要license. 经过摸索终于搞定一键启动并且 ...

  9. vue 图片下载

       getBase64Image(img) {        var canvas = document.createElement("canvas");        canv ...

  10. linux 下用其他用户来执行命令

    sudo su - username -l -c "supervisorctl restart apps" -l , –login:加了这个参数之后,就好像是重新登陆一样,大部分环 ...