博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring Boot 知识笔记(thymleaf模板引擎)
阅读量:4685 次
发布时间:2019-06-09

本文共 898 字,大约阅读时间需要 2 分钟。

一、pom.xml中引入

org.springframework.boot
spring-boot-starter-thymeleaf

二、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页面

    
IndexThis is a index portal!

 

四、新建一个类,把页面跳转至上面新建的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";    //不用加后缀,已在配置文件里面增加配置    }}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/Eleven-Liu/p/11031903.html

你可能感兴趣的文章
关于APK签名的一些东西
查看>>
让IE6 IE7 IE8 IE9 IE10 IE11支持Bootstrap的解决方法
查看>>
innerHTML与innerText的区别
查看>>
git简单配置
查看>>
mvc-1
查看>>
Android 读取文件内容
查看>>
sql server 2008学习8 sql server存储和索引结构
查看>>
Jquery radio选中
查看>>
《Visual C++ 2010入门教程》系列二:安装、配置和首次使用VS2010
查看>>
P1351 联合权值[鬼畜解法]
查看>>
向下之旅(十七):虚拟文件系统(一)
查看>>
正则表达式(笔记)
查看>>
中山大学2007级硕士研究生泛函分析考试题
查看>>
[Everyday Mathematics]20150114
查看>>
linux进程篇 (三) 进程间的通信1 管道通信
查看>>
mysql清表数据
查看>>
.NET Core微服务之基于Polly+AspectCore实现熔断与降级机制
查看>>
1 Acid burn ★ Nag,Name/Serial,Serial
查看>>
DELL服务器iDRAC相关设置
查看>>
Vue实例详解与生命周期
查看>>