SpringBoot目录文件结构总结(5)
1、目录
src/main/java :存放java代码
src/main/resources
static:存放静态文件,比如css、js、image(访问方式 http://localhost:8080/js/main.js)
templates:存放静态页面jsp,html,tpl
config:存放配置文件application.properties
resources:

2、静态文件加载顺序:Spring Boot默认依次从:META/resources > resources >static >public > 如果存在访问的资源则返回,否则报错!
3、引入依赖 Thymeleaf
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
新建controller映射过去,例如404错误页面

package cn.xiaobing.demo.controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class FailController { @RequestMapping(value = "/v1/fail")
public Object fail() {
return "404";
}
}
启动项目:

访问映射地址:

4、static:存放静态文件,比如css、js、image(访问方式 http://localhost:8080/image/500.png)

启动项目:

5、自定义路径访问如

新建配置文件:application.properties
spring.resources.static-locations = classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/testCustom/
启动项目:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.1.RELEASE)
访问资源地址:

6、更多学习请spring官网查询
7、不足之处,后续补充!
SpringBoot目录文件结构总结(5)的更多相关文章
- wordpress目录文件结构说明
wordpress目录文件结构说明 wordpress目录文件结构说明. WordPress文件夹内,你会发现大量的代码文件和3个文件夹wp-admin wp-content wp-include ...
- java~springboot~目录索引
回到占占推荐博客索引 最近写了不过关于java,spring,微服务的相关文章,今天把它整理一下,方便大家学习与参考. java~springboot~目录索引 Java~关于开发工具和包包 Java ...
- springboot目录结构、重要配置文件、重要注解的详解
前面2篇博客已经带着大家搭建了springboot项目,并编写了持久化接口部署到tomcat下访问.这里我们一起补充下springboot的基本信息 一.springboot简单介绍 springbo ...
- Springboot目录结构分析
1 src/main/java 存储源码 2 src/main/resource 资源文件夹 (1)src/main/resource/static 用于存放静态资源,如css.js.图片.文件 ...
- WordPress目录文件结构详细说明
根目录 |-wp-admin | |-css | |-images | |-includes | |-js | |-maint | |-network | |-user |-wp-content | ...
- 2、SpringBoot接口Http协议开发实战8节课(1-6)
1.SpringBoot2.xHTTP请求配置讲解 简介:SpringBoot2.xHTTP请求注解讲解和简化注解配置技巧 1.@RestController and @RequestMapping是 ...
- 小D课堂【SpringBoot】接口Http协议开发实战
---恢复内容开始--- ====================2.SpringBoot接口Http协议开发实战 ============================= 1.SpringBoot ...
- 最新学习springboot 配置注解
一.概述 Spring Boot设计目的是用来简化新Spring应用的初始搭建以及开发过程.Spring Boot并不是对Spring功能上的增强,而是提供了一种快速使用Spring的方式. ...
- 零基础快速入门SpringBoot2.0 (一)
零基础快速入门SpringBoot2.0 (一) 一.SpringBoot2.x依赖环境和版本新特性说明 简介:讲解新版本依赖环境和springboot2新特性概述 1.依赖版本jdk8以上, Spr ...
随机推荐
- Shell系列(9)- 用户自定义变量(2)
定义变量 变量名=变量值 例如: x=123 mulu="当前目录下有 $(ls)" 备注: 变量名只能是字母.下划线.数字组成且不能以数字开头 变量等号两侧不能加空格 若变量值中 ...
- eps出坑出坑
1 visio格式转eps 先将Visio保存为pdf格式文件 使用adobe acrobat编辑pdf 先将文件裁剪至所需大小 随后点编辑,选择全选,然后文件,导出到,内嵌postscript 2 ...
- PHP 合并2个链表
输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. <?php class ListNode{ var $val; var $next = NULL; ...
- 接口测试-Mock测试方法
接口测试-Mock测试方法一.关于Mock测试1.什么是Mock测试?Mock 测试就是在测试过程中,对于某些不容易构造(如 HttpServletRequest 必须在Servlet 容器中才能构造 ...
- 『Python』matplotlib实现动画效果
一般而言,在绘制复杂动画时,主要借助模块animation来完成 import numpy as np import matplotlib.pyplot as plt import matplotli ...
- docker run 参数
一.格式 docker run [OPTIONS] IMAGE [COMMAND] [ARG...] 二.OPTIONS 参数 简写, 名称参数 默认参数 描述 --add-host 添加自定义主机到 ...
- Python3入门系列之-----算术运算符|比较运算符|赋值运算符|逻辑运算符|成员运算符|身份运算符
什么是运算符? 本章节主要说明Python的运算符.举个简单的例子 1 +2 = 3 . 例子中,1 和 1.2 被称为操作数,"+" 称为运算符. Python语言支持以下类型的 ...
- Visual Studio 6.0 在 Windows 10 下崩溃的一种解决方法
Visual Studio 6.0 下载地址: https://winworldpc.com/product/microsoft-visual-stu/60 安装步骤: https://www.cod ...
- UVa/数组与字符串习题集
UVa-272. Description: TEX is a typesetting language developed by Donald Knuth. It takes source text ...
- 【C++ Primer Plus】编程练习答案——第12章
1 // chapter12_1_cow.h 2 3 4 #ifndef LEARN_CPP_CHAPTER12_1_COW_H 5 #define LEARN_CPP_CHAPTER12_1_COW ...