• Spring boot +Thymeleaf 搭建springweb


    对接天猫精灵的时候需要有网关服务器方提供几个页面,服务器已经有了,spring boot的 纯后台的,就加了Thymeleaf   jar包添加几个页面跳转

    maven配置

            <!-- 引入thymeleaf模板引擎-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>
     
        </dependencies>

    yml配置

    spring:
      profiles: shypro
      thymeleaf:
        prefix: classpath:/templates/
        suffix: .html
        mode: LEGACYHTML5
        encoding: UTF-8
        content-type: text/html
        cache: false

    在resource下新建templates目录

    controller的注解是@Controller,return的string是html的文件名

    @Controller
    public class HtmlController {
    
        @RequestMapping("/testhtml")
        public String index(){
            System.out.println("index");
            return "index";
        }
    }

    html的数据渲染看如下博客

    https://www.jianshu.com/p/23bea93e34c7

    https://www.jianshu.com/p/a842e5b5012e

    Thymeleaf 的语法大全

    https://www.cnblogs.com/ityouknow/p/5833560.html

  • 相关阅读:
    哈希表和HashMap内部实现原理
    git入门指导
    eclipse快捷键汇总
    Java Map容器小示例
    Java容器小解析
    泛型小解析
    Python UDP编程小示例
    wcf-2
    wcf-1
    感想
  • 原文地址:https://www.cnblogs.com/heroinss/p/10437591.html
Copyright © 2020-2023  润新知