Spring Boot 知识笔记(thymleaf模板引擎)
一、pom.xml中引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二、application.properties增加相关配置
#开发时关闭缓存,不然没法看到实时页面
spring.thymeleaf.cache=false
spring.thymeleaf.mode=HTML5
#前缀
spring.thymeleaf.prefix=classpath:/templates/
#编码
spring.thymeleaf.encoding=UTF-8
#类型
spring.thymeleaf.content-type=text/html
#名称的后缀
spring.thymeleaf.suffix=.html
三、templates文件夹下新建一个html页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index</title>
</head>
<body>
This is a index portal!
</body>
</html>
四、新建一个类,把页面跳转至上面新建的html
package net.Eleven.demo.controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller //注意这里不要使用RestController注解
@RequestMapping("/thymeleaf")
public class ThymeleafController {
@RequestMapping("hello")
public Object hello(){
return "index"; //不用加后缀,已在配置文件里面增加配置
}
}
Spring Boot 知识笔记(thymleaf模板引擎)的更多相关文章
- Spring Boot (三)模板引擎FreeMarker集成
一.FreeMaker介绍 FreeMarker是一款免费的Java模板引擎,是一种基于模板和数据生成文本(HMLT.电子邮件.配置文件.源代码等)的工具,它不是面向最终用户的,而是一款程序员使用的组 ...
- Spring Boot (四)模板引擎Thymeleaf集成
一.Thymeleaf介绍 Thymeleaf是一种Java XML / XHTML / HTML5模板引擎,可以在Web和非Web环境中使用.它更适合在基于MVC的Web应用程序的视图层提供XHTM ...
- Spring Boot 知识笔记(整合Mybatis)
一.pom.xml中添加相关依赖 <!-- 引入starter--> <dependency> <groupId>org.mybatis.spring.boot&l ...
- Spring Boot 知识笔记(配置文件)
Spring boot 提供了两种常用的配置文件,properties和yml文件. 1.yml yml是YAML(YAML Ain't Markup Language)语言的文件,以数据为中心,比j ...
- Spring Boot 知识笔记(热部署)
热部署原理: 使用了两个ClassLoader,一个Classloader加载那些不会改变的类(第三方Jar包),另一个ClassLoader加载会更改的类,称为restart ClassLoader ...
- Spring Boot 知识笔记(创建maven项目、HTTP接口)
一.使用Maven手工创建SpringBoot应用(IDEA) 1. 点击File——New——Project——Maven——Next,填写相关信息,创建项目. 2. 在pom.xml中添加相关 ...
- Spring Boot 知识笔记(整合Redis)
一.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...
- Spring Boot 知识笔记(定时任务与异步)
一.定时任务 1.启动类里面增加注入 @SpringBootApplication //@SpringBootApplication = @Configuration+@EnableAutoConfi ...
- Spring Boot 知识笔记(集成zookeeper)
一.本机搭建zookeeper伪集群 1.下载安装包,复制三份 2.每个安装包目录下面新建一个data文件夹,用于存放数据目录 3.安装包的conf目录下,修改zoo.cfg配置文件 # The nu ...
随机推荐
- kali 安装 360国产浏览器
1. 下载360安全浏览器国产版本的 amd64 deb的包 https://browser.360.cn/se/linux/index.html 下载到的文件为: browser360-cn-sta ...
- 那些前端二进制操作API
一直以来,前端的工作主要涉及的是字符串操作,而对二进制的数据接触较少.但是这种需求却一直存在着,尤其是HTML5之后,随着web应用越来越复杂,File,Blob,TypedArray这些API的出现 ...
- yml 字典列表
观察: --- # 一位职工记录 name: Example Developer job: Developer skill: Elite employed: True foods: - Apple - ...
- Logstash之控制台输出的两种方式
输出json output { stdout { codec => json } } 输出rubydebug output { stdout { codec => rubydebug } ...
- 《即时消息技术剖析与实战》学习笔记6——IM系统如何保证消息的安全性
在消息产生.流转的各个环节中,需要保证消息传输安全性.消息存储安全性.消息内容安全性. 一.消息传输安全性 消息传输的重要防范点有两个,一是访问入口安全,二是传输链路安全. 1.HttpDNS保证访问 ...
- Javascript屏蔽Backspace回退页面
允许对输入框密码框等控件删除字符,但是不允许页面进行回退 <html lang="en" xmlns="http://www.w3.org/1999/xhtml&q ...
- Qt高仿Excel表格组件-支持冻结列、冻结行、内容自适应和合并单元格
目录 一.概述 二.效果展示 三.实现思路 1.冻结行.冻结列 2.行高自适应 3.蚂蚁线 四.测试代码 1.添加表格数据 2.设置冻结行.列 3.行高.列宽 4.单元格背景色 5.单元格文字 6.其 ...
- React路由安装使用和多种方式传参
安装路由 npm i react-router-dom -S 引入路由 import { BowserRouter as Router, Route, Switch, ... } from " ...
- javascript format 字符串 函数
函数实现如下: function format(string) { var args = arguments; var pattern = new RegExp("%([1-" + ...
- vue底部导航的精准显示
让底部导航只显示在一级页面: 路由中的写法: import Vue from 'vue' import Router from 'vue-router' //import HelloWorld fro ...