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 ...
随机推荐
- Map-560. Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarra ...
- Binary Search-483. Smallest Good Base
For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1. Now given a str ...
- 解决spring的java.lang.IllegalArgumentException异常
解决办法是: 右击项目 ---> properties --->project facets : 修改JDK版本,需要将1.8 降为1.7版本.
- 将一个List拆分为n份的方法
public static void main(String[] args) { List<Integer> taskList = new ArrayList<>(); for ...
- ffmpeg开发基础知识
1.音频采集 面临的问题:延时敏感,噪声消除,回声消除,静音检测 主要参数: 采样率,位宽,声道数,音视频帧 采样率: 也称为采样速度或者采样率,定义了每秒从连续信号中提取并组成离散信号的采样个数,它 ...
- 移动端页面模板viewport
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <meta nam ...
- 实验三:分别用for、while和do-while循环语句以及递归方法计算n!,并输出算式
一.用for循环计算n! package for_package; import java.util.*;//导入含有输入类的包 public class for_class { /** * @par ...
- J02-Java IO流总结二 《概述》
1 流的概念 流是一个信息的通道,通过通道可以访问通道连接的文件对象. 2 流的分类 根据流中数据的流向,可分为输入流和输出流 输入流:从其他的地方流入到程序内存中的,比如InputStream. ...
- AsyncTask的前世今生
先看下Java Threading Framework的类图: Callable与Runnable类似,差别在Callable具有返回值,共同点是两个都是执行体,一般都抽象为任务处理. ...
- Mapreduce部署与第三方依赖包管理
Mapreduce部署是总会涉及到第三方包依赖问题,这些第三方包配置的方式不同,会对mapreduce的部署便捷性有一些影响,有时候还会导致脚本出错.本文介绍几种常用的配置方式: 1. HADOOP_ ...