IDEA SpringBoot +thymeleaf配置
1、pom添加以下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
之后更新maven

2、在application.properties中可以配置thymeleaf模板解析器属性
#thymeleaf start
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
#开发时关闭缓存,不然没法看到实时页面
spring.thymeleaf.cache=false
#static 文件夹下的静态文件访问路径
spring.mvc.static-path-pattern=/**
#thymeleaf end
3、编写DEMO
控制器
package com.example.demo; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
@RequestMapping(value = "/hello")
public class HelloController {
@RequestMapping(value = "/index")
public String hello(Model model) {
model.addAttribute("name", "Dear");
return "hello";
}
}
view
在resources下的templates下新建hello.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h2 data-th-text="${name}"></h2>
</body>
</html>
地址中输入http://localhost:8080/hello/index
结果:

配置成功!
IDEA SpringBoot +thymeleaf配置的更多相关文章
- SpringBoot Thymeleaf 配置多个Template Locations
@Configuration public class ThymeleafConfigration { @Bean public SpringResourceTemplateResolver firs ...
- springboot+maven+thymeleaf配置实战demo
本案例使用thymeleaf,与springboot配置使用.thymeleaf是一种模板语言,可以动态或者静态显示文本内容. 1 .项目结构 2.构建springboot项目 通过idea的new ...
- SpringBoot+thymeleaf+security+vue搭建后台框架 基础篇(一)
刚刚接触SpringBoot,说说踩过的坑,主要的还是要记录下来,供以后反省反省! 今天主要讲讲 thymeleaf+security 的搭建,SpringBoot的项目搭建应该比较简单,这里就不多说 ...
- 电商门户网站商品品类多级联动SpringBoot+Thymeleaf实现
在淘宝.京东等电商网站,其门户网站都有一个商品品类的多级联动,鼠标移动,就显示,因为前端不是我做的,所以不说明前端实现,只介绍后端实现. 搭建部署SpringBoot环境 配置文件配置: 开启了对Th ...
- springboot+thymeleaf简单使用
关于springboot想必很多人都在使用,由于公司项目一直使用的是SpringMVC,所以自己抽空体验了一下springboot的简单使用. 环境搭建 springbooot的环境搭建可以说很灵活, ...
- SpringBoot 国际化配置,SpringBoot Locale 国际化
SpringBoot 国际化配置,SpringBoot Locale 国际化 ================================ ©Copyright 蕃薯耀 2018年3月27日 ht ...
- SpringBoot thymeleaf模板版本,thymeleaf模板更换版本
SpringBoot thymeleaf模板版本 thymeleaf模板更换版本 修改thymeleaf模板版本 ================================ ©Copyright ...
- springboot中配置主从redis
测试redis的主从配置 redis实例 文件夹名称如下 redis_master_s redis_slaver1_s redis_slaver2_s redis.conf文件 master的redi ...
- 不要再学 JSP 了,学 SpringBoot + Thymeleaf + Vue吧
老读者就请肆无忌惮地点赞吧,微信搜索[沉默王二]关注这个在九朝古都洛阳苟且偷生的程序员.本文 GitHub github.com/itwanger 已收录,里面还有我精心为你准备的一线大厂面试题. 读 ...
随机推荐
- hdu 2222 Keywords Search——AC自动机
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2222 第一道AC自动机! T了无数边后终于知道原来它是把若干询问串建一个自动机,把模式串放在上面跑:而且只 ...
- 洛谷P3386——二分图匹配
题目:https://www.luogu.org/problemnew/show/P3386 二分图匹配模板,注意左部点只dfs未匹配点. 代码如下: #include<iostream> ...
- DB2 Error Messages (Sorted by SQLCODE)
DB2 Error Messages (Sorted by SQLCODE) DB2 Error Messages (Sorted by SQLCODE) SQLCODE SQLSTATE Descr ...
- Nuget:RQCode
ylbtech-Nuget:QRCode 1.返回顶部 1. https://www.nuget.org/packages?q=qrcode 2. 2.qrcode.js返回顶部 1. https:/ ...
- 常量指针-指向常量的指针,指针常量-指针本身是常量,常量-不能更改值的常量,数组指针-是指针int (*p)[n] 指针数组-是数组int *p[n]
1.常量指针 定义:具有只能够读取内存中数据,却不能够修改内存中数据的属性的指针,称为指向常量的指针,简称常量指针. 声明:const int * p; int const * p; 注:可以将一个常 ...
- MVVM里绑定TreeView控件的SelectedItem
<TreeView x:Name="treeView"> <i:Interaction.Triggers> <i:EventTrigger Event ...
- css hack汇总
注意点: 网上很多资料中常常把!important也作为一个hack手段,其实这是一个误区.!important常常被我们用来更改样式,而不是兼容hack.造成这个误区的原因是IE6在某些情况下不主动 ...
- 根据xml文件自动生成xsd文件
根据xml生成xsd文档 1. 找到vs自带的xsd.exe工具所在的文件夹位置: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin 注意 ...
- 读取静态Json文件
创建web项目: string Json = string.Empty; string filePath = Server.MapPath("/***.json");//根目录下的 ...
- MVC+Linq+EF笔记
using (DataContext ctx = new DataContext()) { /*foreach (var item in ctx.employees) { ViewData[" ...