Spring Boot使用Html
2024-09-18 18:50:50
1、引入模板thymeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
增加配置
spring:
thymeleaf:
prefix: classpath:/templates/
2、增加接口
@RequestMapping("/hello")
public String helloHtml(HashMap<String, Object> map) {
map.put("hello", "hello world~");
return "/index";
}
3、创建Html页面 index.html 路径为:resources/templates/index.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>Title</title>
</head>
<body>
<p th:text="${hello}"></p>
</body>
</html>
4、查看效果
最新文章
- 不能在DropDownList 中选择多个项
- HTML+CSS--继续学习
- tomcat 性能优化
- Azure 删除VHD时报错:There is currently a lease on the blob and no lease ID was specified in the request
- iOS中发送HTTP请求的方案
- PIT,BL,AP,CP,CSC
- 团队开发之《极速蜗牛》NABC分析
- 关于面向对象--oop
- hdu 4335 What is N?
- 查看ssh服务开启状态
- uva 10036 Problem C: Divisibility
- Golang网络库中socket阻塞调度源码剖析
- Java反射机制小例子
- VMware运行gazebo,关于vmw_ioctl_command error Invalid argument错误
- 正向代理or反向代理
- 解决微信小程序的wx-charts插件tab切换时的显示会出现位置移动问题-tab切换时,图表显示错乱-实现滑动tab
- HTML5-CSS3-JavaScript(3)
- QQ分享-定制分享卡片
- Android实现圆形的图片边角
- 如何读取jar包外的properties文件和log4j.properties