【SpringBoot】10.SpringBoot文件上传
SpringBoot整合Thymeleaf
1.创建Thymeleaf的入门项目
maven构建简单项目
修改pom文件添加thymeleaf的坐标
<!-- thymeleaf的坐标 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
创建存放视图的目录:src/main/resources/templates
templates:该目录是安全的,意味着该目录下的内容是不允许外界直接访问的(不能通过url直接访问)。

2.Thymeleaf的基本使用
1.Thymeleaf的特点
Thymeleaf是通过他特定的语法对html的标记做渲染。
2.编写controller
/**
* Thymeleaf 入门案例
*/
@Controller
public class DemoController {
@RequestMapping("/show")
public String showInfo(Model model) {
model.addAttribute("msg","Thymeleaf 第一个案例");
return "index";
}
}
3.编写页面
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Thymeleaf 入门</title>
</head>
<body>
<span th:text="Hello"></span>
<hr/>
<span th:text="${msg}"></span>
</body>
</html>
4.编写启动器
5.运行
有可能会出现没有html结束标记的异常:
我的项目的Springboot的版本是2.1.2所以没有出现此异常
- 加上结束标记即可。让html的标记按照严谨的语法编写。
- 修改导入的Thymeleaf的jar包的版本到 3.0以上
<properties>
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.0.4</thymeleaf-layout-dialect.version>
</properties>
【SpringBoot】10.SpringBoot文件上传的更多相关文章
- SpringBoot项目实现文件上传和邮件发送
前言 本篇文章主要介绍的是SpringBoot项目实现文件上传和邮件发送的功能. SpringBoot 文件上传 说明:如果想直接获取工程那么可以直接跳到底部,通过链接下载工程代码. 开发准备 环境要 ...
- Springboot如何启用文件上传功能
网上的文章在写 "springboot文件上传" 时,都让你加上模版引擎,我只想说,我用不上,加模版引擎,你是觉得我脑子坏了,还是觉得我拿不动刀了. springboot如何启用文 ...
- SpringBoot+BootStrap多文件上传到本地
1.application.yml文件配置 # 文件大小 MB必须大写 # maxFileSize 是单个文件大小 # maxRequestSize是设置总上传的数据大小 spring: servle ...
- springboot+vue实现文件上传
https://blog.csdn.net/mqingo/article/details/84869841 技术: 后端:springboot 前端框架:vue 数据库:mysql pom.xml: ...
- SpringBoot之KindEditor文件上传
后端核心代码如下: package com.blog.springboot.controller; import java.io.BufferedOutputStream; import java.i ...
- SpringBoot: 6.文件上传(转)
1.编写页面uploadFile.html <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- Springboot(九).多文件上传下载文件(并将url存入数据库表中)
一. 文件上传 这里我们使用request.getSession().getServletContext().getRealPath("/static")的方式来设置文件的存储 ...
- springboot升级导致文件上传自动配置/tmp目录问题解决
1,..\web\src\main\resources\spring\web-men-applicationContext.xml 保留原有的bean配置 <bean id="mult ...
- 170706、springboot编程之文件上传
使用thymleaf模板,自行导入依赖! 一.单文件上传 1.编写单文件上传页面singleFile.html <!DOCTYPE html> <html xmlns="h ...
- SpringBoot之MultipartFile文件上传(6)
1.静态文件 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <ti ...
随机推荐
- C++ 关键字 enum
转自:https://blog.csdn.net/cppwork/article/details/18814315 C++ 关键字 enum. 枚举 1. 概念 我们经常需要为某些属性定义一组可选择 ...
- matlab中fft快速傅里叶变换
视频来源:https://www.bilibili.com/video/av51932171?t=628. 博文来源:https://ww2.mathworks.cn/help/matlab/ref/ ...
- WebStrom配置TypeScript开发环境
安装NodeJS node.js下载地址:https://nodejs.org/en/download/ 安装TypeScript npm install typescripot -g 新建tscon ...
- 联赛模拟测试14 A. 虎
题目描述 这题太虎了,所以没有背景. 给你一棵树,边有黑白两种颜色,你每次可以选择两个点,把这两个点之间的唯一简单路径上的所有边颜色取反,某些边要求最终颜色必须是黑色,还有些边没有要求,问最少操作多少 ...
- 11 . Nginx核心原理讲解
应用场景优缺点 应用场景 // 1.静态请求 // 2.反向代理 // 3.负载均衡 // 4.资源缓存 // 5.安全防护 // 6.访问限制IP // 7.访问认证 /* 核心主要是以下三个应用: ...
- ansible-playbook简介
1. ansible-playbook简介 • Playbooks 与 adhoc 相比,是一种完全不同的运用 ansible 的方式,是非常之强大的. • 简单来说,playbooks 是一种简单的 ...
- Springboot+JPA下实现简易爬虫:豆瓣电视剧数据
Springboot+JPA下实现简易爬虫:豆瓣电视剧数据 前言:今天听到产品那边讨论一些需求,好像其中一点是用户要求我们爬虫,在网页上抓取一些数据然后存到我们公司数据库中,众所周知,爬虫的实现对于p ...
- python程序整理(1)
''' 用户登录验证 要求: 1. 系统⾃动⽣成4位随机数. 作为登录验证码. 直接用就好. 这里不用纠结 提示. 生成随机数的办法. from random import randint num = ...
- Apollo基于K8S的部署以及接入
Apollo镜像服务 基于开源Apollo服务进行相关服务镜像打包,实际将分发apollo-adminservice.apollo-configservice和apollo-portal 这三个镜像安 ...
- Centos7 安装python环境
保留python2 找到python所在位置,把python指向python2.7备份 [root@sun /usr/bin]# cd ~ [root@sun ~]# whereis python p ...