22.springboot freemarker -thymeleaf

1,添加jar

<!--themplates模板-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

2,在 项目 src\main\resources\templates 下新建 login.html

3,在controller层跳转页面‘

@Controller    //注意这里只能controller    不能RestController
@RequestMapping(value="/index")
public class IndexController {
   @RequestMapping(value="/aa",method= RequestMethod.GET)
       public  String test(HttpServletRequest request) {
        //逻辑处理
      request.setAttribute("key", "hello world"); //向前台传参
        return "login";  //跳转到页面
    }
}

4,前台接受传参

<body>
  themplates模板

  [[${key}]]     //接受的值
</body>

5,tmpl的html 读取静态配置的路径
![IMG_20190219_112736406.jpg](https://upload-images.jianshu.io/upload_images/12197462-9a7170a0e36221ca.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


<script src="/layui/layui.js"></script>
<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" >
<link rel="stylesheet" href="/layui/css/layui.css" media="all" >

这2 个方法都可以.因为layui在webapp下面 所以 去掉 wabapp  换成 /  下面就写全路径    
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • jHipster - 微服务搭建 CC_简书[https://www.jianshu.com/u/be0d56c4...
    quanjj阅读 846评论 0 2
  • JSPXCMS开发架构介绍 V1 – 架构概述 基本概述 配置文件目录 /src/main/resources/...
    Java_Evan阅读 4,467评论 0 0
  • 继上篇文章:Spring-Boot入门之环境搭建。这次我们整合SpringBoot-Mybatis实现简单的CRU...
    TyCoding阅读 9,262评论 3 60
  • 话说山东东平县有个叫王里直的财主,这人贪财好色。长的是八字刀须眉,日月眼,玄田的鼻,牛生的耳,嘴边还长这一撮黑毛,...
    三悟阅读 545评论 1 2
  • 黑暗被卷入大海里 呼声高过风里的空气 我看见你 我们之间隔着一片淡蓝色的海湾 努力拥抱的姿势沾染上了潮气 你轻轻地...
    夏成荫阅读 234评论 0 0