在pom.xml当中加入这俩个依赖

         <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>

NekoHTML 是HTML扫描器和标签补偿器,能增补缺失的父元素、自动用结束标签关闭相应的元素,以及不匹配的内嵌元素标签。

application.properties

##端口号
server.port=8888
##去除thymeleaf的html严格校验
spring.thymeleaf.mode=LEGACYHTML5
#设定thymeleaf文件路径 默认为src/main/resources/templates
spring.freemarker.template-loader-path=classpath:/templates
#设定静态文件路径,js,css等
spring.mvc.static-path-pattern=/static/**
#是否开启模板缓存,默认true
#建议在开发时关闭缓存,不然没法看到实时页面
spring.thymeleaf.cache=false
#模板编码
spring.freemarker.charset=UTF-8

ThymeleafController.java

@Controller
public class ThymeleafController {
@RequestMapping(value = "/")
public String thymeleafTest(ModelMap modelMap) {
modelMap.addAttribute("msg", "你好公子潘");
modelMap.addAttribute("tag", "http://localhost:8080/gtvg/order/details");
int[] s=new int[]{9,9,34};
modelMap.addAttribute("one","s");
List<Map<String,Object>>list=new ArrayList<>();
Map<String,Object>m=new HashMap<>();
m.put("name","pan");
list.add(m);
m=new HashMap<>();
m.put("name","chen");
list.add(m);
m=new HashMap<>();
m.put("name","chenyiqiao");
list.add(m);
m=new HashMap<>();
m.put("name","kai");
list.add(m); modelMap.addAttribute("list",list);
return "thymeleaf";
} @RequestMapping(value = "/tag")
public String tag()
{
return "test";
}
}

thymeleaf.html

<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"> <head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div th:text="${msg}"></div>
<div th:text="${tag}"></div>
<input type="text" th:value="${msg}">
<a th:href="@{https://cdn2.jianshu.io/assets/web/nav-logo-4c7bbafe27adc892f3046e6978459bac.png}">
超链接</a>
<a th:href="@{tag}">controller跳转</a>
<img th:src="${'https://123p3.sogoucdn.com/imgu/2018/04/20180404144123_595.png'}"/> <div th:each="m,iterStat : ${list}">
<div th:text="${m.name}"></div>
<span th:text="'index:'+${iterStat.index}"></span>
<span th:text="${'count:'+iterStat.count}"></span>
<span th:text="'current:'+${iterStat.current}"></span>
<span th:text="${'odd:'+iterStat.odd}"></span>
<span th:text="${'even:'+iterStat.even}"></span>
<span th:text="${'size:'+iterStat.size}"></span>
</div>
</body>
</html>

test.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
test
</body>
</html>

个人网站

SpringBoot+thymelates入门的更多相关文章

  1. SpringData 基于SpringBoot快速入门

    SpringData 基于SpringBoot快速入门 本章通过学习SpringData 和SpringBoot 相关知识将面向服务架构(SOA)的单点登录系统(SSO)需要的代码实现.这样可以从实战 ...

  2. SpringBoot Docker入门,SpringBoot Docker安装

    SpringBoot Docker入门,SpringBoot Docker安装 ================================ ©Copyright 蕃薯耀 2018年4月8日 ht ...

  3. 01-项目简介Springboot简介入门配置项目准备

    总体课程主要分为4个阶段课程: ------------------------课程介绍------------------------ 01-项目简介Springboot简介入门配置项目准备02-M ...

  4. SPRING-BOOT系列之SpringBoot快速入门

    今天 , 正式来介绍SpringBoot快速入门 : 可以去如类似 https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/refer ...

  5. SpringBoot快速入门01--环境搭建

    SpringBoot快速入门--环境搭建 1.创建web工程 1.1 创建新的工程. 1.2  选择maven工程,点击下一步. 1.3 填写groupid(maven的项目名称)和artifacti ...

  6. SpringBoot 初入门

    SpringBoot 初入门 关于介绍什么之类的就不讲了,主要做一下学习记录. 1. 启动方式 IDEA 启动 命令行启动: mvn spring-boot:run 部署到服务器启动: 先进行打包, ...

  7. springBoot从入门到源码分析

    先分享一个springBoot搭建学习项目,和springboot多数据源项目的传送门:https://github.com/1057234721/springBoot 1. SpringBoot快速 ...

  8. SpringBoot基础篇-SpringBoot快速入门

    SpringBoot基础 学习目标: 能够理解Spring的优缺点 能够理解SpringBoot的特点 能够理解SpringBoot的核心功能 能够搭建SpringBoot的环境 能够完成applic ...

  9. Springboot快速入门篇,图文并茂

    Springboot快速入门篇,图文并茂 文章已托管到GitHub,大家可以去GitHub查看阅读,欢迎老板们前来Star!搜索关注微信公众号 [码出Offer] 领取各种学习资料! image-20 ...

随机推荐

  1. Day 39 管道 、数据共享与地址池

    参考张磊同学的博客 http://www.cnblogs.com/chongdongxiaoyu/p/8658379.html 一.管道 #创建管道的类: Pipe([duplex]):在进程之间创建 ...

  2. neutron openvswitch + vxlan 通讯

  3. 用layui遇到过的问题

    1.报错“layui.form is not a function”问题 把代码中这一串修改一下:form = layui.form(); 括号去掉就行: form = layui.form; 如果你 ...

  4. CRUD组件的高阶使用

    1.list页面自定列显示: class PermissionConfig(sites.AryaConfig):       def dabo(self, obj=None, is_header=Fa ...

  5. jzoj3519

    我們考慮將一個節點x的所有兒子的數都改成y 記lcm[x]表示一個點的所有子節點的lcm值 那麼我們會發現y*deg[x] 要被lcm[x]整除 那麼x就會比x所有子節點最小的數小,記為z 那麼x就是 ...

  6. Recursion-687. Longest Univalue Path

    Given a binary tree, find the length of the longest path where each node in the path has the same va ...

  7. Flask从入门到精通之在视图函数中处理表单

    在新版hello.py 中,视图函数index() 不仅要渲染表单,还要接收表单中的数据.更新后的index() 视图函数如下: @app.route('/') def index(): name = ...

  8. day 32 css后续补充以及js 简单入门

    前情提要: 利用html 和css ,js 模拟小米的官网(待做) 一:第一个sj利子 <!DOCTYPE html> <html lang="en"> & ...

  9. vue项目在IE下报 [vuex] vuex requires a Promise polyfill in this browser问题

    如下图所示,项目在IE11下打开报错: 因为使用了 ES6 中用来传递异步消息的的Promise,而IE浏览器都不支持. 解决方法: 第一步: 安装 babel-polyfill . babel-po ...

  10. Andrew Ng机器学习第三章——线性回归回顾

    一些概念: 向量:向量在矩阵中表示为只有一列的矩阵 n维向量:N行1列的矩阵. 利用矩阵计算可以快速实现多种结果的计算. 如下图,给出四个房子大小的样本,有四个假设函数对房子价格进行预测.构造下面的矩 ...