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 已收录,里面还有我精心为你准备的一线大厂面试题. 读 ...
随机推荐
- AR/VR-AR:AR
ylbtech-AR/VR-AR:AR 增强现实技术(Augmented Reality,简称 AR),是一种实时地计算摄影机影像的位置及角度并加上相应图像.视频.3D模型的技术,这种技术的目标是在屏 ...
- 条款20.宁以pass-by-reference-to-const替换pass-by-vlaue
缺省情况下c++以by value的方式传递对象至(或来自)函数.除非你另外指定,否则函数参数都是以实际实参的复件(副本)为初值,而调用端所获得的亦是函数返回值的一个复件.这些复件是由对象的c ...
- UVaLive 4731 Cellular Network (期望DP)
题意:手机在蜂窝网络中的定位是一个基本问题,假设蜂窝网络已经得知手机处于c1,c2,,,cn这些区域中的一个,最简单的方法是同时在这些区域中寻找手机, 但这样做很浪费带宽,由于蜂窝网络中可以得知手机在 ...
- SAP ECC6 IDES安装及虚拟机下载
SAP ECC6.0 SR3 IDES Oracle.torrent(48.12G)下载 SAP ECC6 安装系列 SAP ECC6.0 IDES在Win7 X64上的安装 SAP ECC6.0 R ...
- httpd.conf------Apache主站点配置
Apache主站点配置 Apache的配置由httpd.conf文件配置,因此下面的配置指令都是在httpd.conf文件中修改. Apache主站点基本配置:ServerRoot “/mnt/sof ...
- 实现简易版shell
操作系统小组作业,实现一个简易shell,shell实现了下列命令 exit------退出终端命令 clr-------清屏命令 time-----时间命令 myshell----欢迎命令 quit ...
- Unity 5 全局光照GI与新的烘焙系统初探
http://blog.csdn.net/sparrowfc/article/details/45650013 GI是啥 Realtime GI,实时全局光照,听上去就是一个非常高大上的词,但是越高大 ...
- 计蒜课/UCloud 的安全秘钥(hash)
题目链接:https://nanti.jisuanke.com/t/15768 题意:中文题诶- 思路:直接hash就好了,当时zz了没想到... 代码: #include <iostream& ...
- 洛谷P1014 Cantor表
P1014 Cantor表 题目描述 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 ...
- 洛谷P1556 幸福的路
P1556 幸福的路 题目描述 每天,John都要为了农场里N(1≤N≤10)头牛的健康和幸福四处奔波. 每头牛的位置可以描述为一个二维坐标,John从坐标原点(0,0)出发.为了使路径更有趣,Joh ...