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 ...
随机推荐
- 华为交换机 查看 ip和mac对应关系
IPv4: display arp IPv6: display ipv6 neighbors
- jQuery基础笔记(3)
day55 参考:https://www.cnblogs.com/liwenzhou/p/8178806.html#autoid-1-8-0 操作标签 样式操作 样式类 addClass();// 添 ...
- poj1456---贪心
题目大意: 有n个商品,每个商品有价值和一个最后期限,过了这个期限该商品就不能卖出去了 问你如何去卖,能得到最大的收益.(每个东西卖一天,不能同时卖两种东西) 思路: 贪心: 先按价值对商品排序,价值 ...
- 转载:不定义JQuery插件,不要说会JQuery
转载:http://www.cnblogs.com/xcj26/p/3345556.html 一:导言 有些WEB开发者,会引用一个JQuery类库,然后在网页上写一写$("#") ...
- Ubuntu 16.04LTS安装Nginx
Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 Igor Sysoev ...
- jquery, jquery-ui, requirejs, bootstrap 的关系理解
jquery 是 基于 javascript 的一个语法衍生,更方便操作dom, 事件,css 整体来说更好用,更简洁. jquery-ui 是基于 jquery 实现的各种更好看,交互更友好的的界面 ...
- spring cloud ribbon源码解析(二)
在上一篇文章中主要梳理了ribbon的执行过程,这篇主要讲讲ribbon的负载均衡,ribbon的负载均衡是通过ILoadBalancer来实现的,对ILoadBalancer有以下几个类 1.Abs ...
- 【codeforces 24D】损坏的机器人
题目大意:有一只坏了的机器人站在一个n∗m的网格里,初始位置在(x,y).现在每个单位时间内它会随机选左右下三个方向走,如果它随机的方向会走出网格就不会往这个方向走.当然这个机器人也可能原地停留一个单 ...
- chrome下uploadify导致页面崩溃
解决方法在初始化uploadify之前用timeout来延迟加载 $(function(){ setTimeout(function(){ $('#file_upload'). ...
- expect中使用exec执行shell命令
今天想在expect脚本中获取本机ip,执行脚本是报错,脚本如下: set localip [exec ifconfig eth0 | grep Mask | cut -d: -f2 | awk '{ ...