SpringBoot+thymelates入门
在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入门的更多相关文章
- SpringData 基于SpringBoot快速入门
SpringData 基于SpringBoot快速入门 本章通过学习SpringData 和SpringBoot 相关知识将面向服务架构(SOA)的单点登录系统(SSO)需要的代码实现.这样可以从实战 ...
- SpringBoot Docker入门,SpringBoot Docker安装
SpringBoot Docker入门,SpringBoot Docker安装 ================================ ©Copyright 蕃薯耀 2018年4月8日 ht ...
- 01-项目简介Springboot简介入门配置项目准备
总体课程主要分为4个阶段课程: ------------------------课程介绍------------------------ 01-项目简介Springboot简介入门配置项目准备02-M ...
- SPRING-BOOT系列之SpringBoot快速入门
今天 , 正式来介绍SpringBoot快速入门 : 可以去如类似 https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/refer ...
- SpringBoot快速入门01--环境搭建
SpringBoot快速入门--环境搭建 1.创建web工程 1.1 创建新的工程. 1.2 选择maven工程,点击下一步. 1.3 填写groupid(maven的项目名称)和artifacti ...
- SpringBoot 初入门
SpringBoot 初入门 关于介绍什么之类的就不讲了,主要做一下学习记录. 1. 启动方式 IDEA 启动 命令行启动: mvn spring-boot:run 部署到服务器启动: 先进行打包, ...
- springBoot从入门到源码分析
先分享一个springBoot搭建学习项目,和springboot多数据源项目的传送门:https://github.com/1057234721/springBoot 1. SpringBoot快速 ...
- SpringBoot基础篇-SpringBoot快速入门
SpringBoot基础 学习目标: 能够理解Spring的优缺点 能够理解SpringBoot的特点 能够理解SpringBoot的核心功能 能够搭建SpringBoot的环境 能够完成applic ...
- Springboot快速入门篇,图文并茂
Springboot快速入门篇,图文并茂 文章已托管到GitHub,大家可以去GitHub查看阅读,欢迎老板们前来Star!搜索关注微信公众号 [码出Offer] 领取各种学习资料! image-20 ...
随机推荐
- CRT和EXCRT简单学习笔记
中国剩余定理CRT 中国剩余定理是要求我们解决这样的一类问题: \[\begin{cases}x\equiv a_1\pmod {b_1} \\x\equiv a_2 \pmod{b_2}\\...\ ...
- 诸神眷顾的幻想乡(zjoi2015,bzoj3926)(广义后缀自动机)
幽香是全幻想乡里最受人欢迎的萌妹子,这天,是幽香的2600岁生日,无数幽香的粉丝到了幽香家门前的太阳花田上来为幽香庆祝生日. 粉丝们非常热情,自发组织表演了一系列节目给幽香看.幽香当然也非常高兴啦. ...
- 设置jade高亮
来自:https://segmentfault.com/a/1190000002896247 打开sublime3,再打开 view > show console,把下列代码复制到console ...
- zookeeper集群环境搭建详细图文教程
zookeeper集群环境搭建详细图文教程 zhoubang @ 2018-01-02 [文档大纲] 友情介绍 软件环境 注意点 环境安装 1. 新建用于存储安装包以及软件安装的目录 2. 下载安装z ...
- 非常好用的@ResponseBody注解
AJAX的写法: ajax接收json格式: ①如果ajax接收的是text dataType:"text", var json = eval("(" + da ...
- string的七种用法
以下是string的七种用法,注意哦,记得要时常去查看java的API文档,那个里面也有很详细的介绍 1>获取 1.1:字符串中包含的字符数,也就是字符串的长度. int length():获 ...
- 2、如何解决xamarin没有相关教程的的指导贴
本篇文章主要在于解决xamarin相关文档偏少的问题. 最终的代码并不重要.重要的还是那种处理的方式 授人以渔 群里有群友讨论说需要读取安卓的 充电电流.这样的问题实际上在原生java有一堆.但是到了 ...
- ActiveMQ-在Centos7下安装和安全配置
环境准备: JDK1.8 ActiveMQ-5.11 Centos7 1.下载Linux版本的ActiveMQ: $ wget http://apache.fayea.com/activemq/5.1 ...
- 《Algorithms算法》笔记:优先队列(1)——API和初等实现
1.优先队列的API和初等实现 做一个总结: 栈 :先进后出 队列 :先进先出 随机队列 : 随机出 优先队列:每次出来的是最大值或最小值 1.1优先队列的API 优先队列在很多场合都有用, 比如:在 ...
- C/C++ -- Gui编程 -- Qt库的使用 -- Qt编码问题
1.直接使用QObject::trUtf8("中文字符串") 2.头文件<QTextCodec>QTextCodec::setCodecForTr(QTextCodec ...