1. 引入相关依赖, 重点是thymeleaf依赖
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2.在 application.properties 【src/main/resources】配置
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
3.html文件

fileUpload.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<meta charset="UTF-8" />
<title>fileUpload page</title>
</head>
<body>

本文介绍了如何在Springboot项目中配置HTML页面跳转,并提供了文件上传和下载的功能。主要步骤包括引入Thymeleaf依赖,配置application.properties,创建HTML文件如fileUpload.html和multifileUpload.html,编写FileUploadController.java控制器代码,最后演示了如何访问和测试这些功能。
最低0.47元/天 解锁文章
1500

被折叠的 条评论
为什么被折叠?



