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)的更多相关文章

  1. wordpress目录文件结构说明

    wordpress目录文件结构说明   wordpress目录文件结构说明. WordPress文件夹内,你会发现大量的代码文件和3个文件夹wp-admin wp-content wp-include ...

  2. java~springboot~目录索引

    回到占占推荐博客索引 最近写了不过关于java,spring,微服务的相关文章,今天把它整理一下,方便大家学习与参考. java~springboot~目录索引 Java~关于开发工具和包包 Java ...

  3. springboot目录结构、重要配置文件、重要注解的详解

    前面2篇博客已经带着大家搭建了springboot项目,并编写了持久化接口部署到tomcat下访问.这里我们一起补充下springboot的基本信息 一.springboot简单介绍 springbo ...

  4. Springboot目录结构分析

    1 src/main/java 存储源码 2 src/main/resource 资源文件夹    (1)src/main/resource/static 用于存放静态资源,如css.js.图片.文件 ...

  5. WordPress目录文件结构详细说明

    根目录 |-wp-admin | |-css | |-images | |-includes | |-js | |-maint | |-network | |-user |-wp-content | ...

  6. 2、SpringBoot接口Http协议开发实战8节课(1-6)

    1.SpringBoot2.xHTTP请求配置讲解 简介:SpringBoot2.xHTTP请求注解讲解和简化注解配置技巧 1.@RestController and @RequestMapping是 ...

  7. 小D课堂【SpringBoot】接口Http协议开发实战

    ---恢复内容开始--- ====================2.SpringBoot接口Http协议开发实战 ============================= 1.SpringBoot ...

  8. 最新学习springboot 配置注解

    一.概述      Spring Boot设计目的是用来简化新Spring应用的初始搭建以及开发过程.Spring Boot并不是对Spring功能上的增强,而是提供了一种快速使用Spring的方式. ...

  9. 零基础快速入门SpringBoot2.0 (一)

    零基础快速入门SpringBoot2.0 (一) 一.SpringBoot2.x依赖环境和版本新特性说明 简介:讲解新版本依赖环境和springboot2新特性概述 1.依赖版本jdk8以上, Spr ...

随机推荐

  1. Java学习之随堂笔记系列——day03

    内容回顾:1.标识符和类型转换    1.1 标识符:给类.方法.变量取得名字就是标识符.        命名规则:            1.必须是字母.数字._.$组成            2. ...

  2. Uncaught TypeError: upload is not a function at HTMLInputElement.onclick

    js 中标签的id名称不能和方法名一样, <tr> <td><input type="button" id="login" val ...

  3. 鸿蒙内核源码分析(系统调用篇) | 开发者永远的口头禅 | 百篇博客分析OpenHarmony源码 | v37.03

    百篇博客系列篇.本篇为: v37.xx 鸿蒙内核源码分析(系统调用篇) | 开发者永远的口头禅 | 51.c.h .o 任务管理相关篇为: v03.xx 鸿蒙内核源码分析(时钟任务篇) | 触发调度谁 ...

  4. P3480-[POI2009]KAM-Pebbles【阶梯博弈】

    正题 题目链接:https://www.luogu.com.cn/problem/P3480 题目大意 \(n\)个石头堆上进行\(\text{Nim}\)游戏,不过需要满足每次操作前后都有\(a_i ...

  5. P3170-[CQOI2015]标识设计【插头dp】

    正题 题目链接:https://www.luogu.com.cn/problem/P3170 题目大意 给出\(n*m\)的网格上有一些障碍,要求用三个\(L\)形(高宽随意,不能退化成线段/点)覆盖 ...

  6. ASP.NET Core 学习笔记 第二篇 依赖注入

    前言 ASP.NET Core 应用在启动过程中会依赖各种组件提供服务,而这些组件会以接口的形式标准化,这些组件这就是我们所说的服务,ASP.NET Core框架建立在一个底层的依赖注入框架之上,它使 ...

  7. 用SpringBoot实现策略模式

    问题的提出 阅读别人代码的时候最讨厌遇到的就是大段大段的if-else分支语句,一般来说读到下面的时候就忘了上面在判断什么了.很多资料上都会讲到使用策略模式来改进这种代码逻辑. 策略模式的类图如下: ...

  8. keepalived-master-slave

    Master配置 global_defs { notification_email { root@localhost } notification_email_from keeplived@local ...

  9. 第一个Java HelloWorld

    步骤 1.在记事本或者notePad++中编写java代码 public class Hello { public static void main(String[] args){ System.ou ...

  10. (Java)面向对象的三大特征

    封装.继承与多态 封装 封装的作用(好处) 提高程序安全性,保护数据 隐藏代码的实现细节 统一接口 增加系统可维护性 属性私有(关键字private) 加上Private可使该属性私有于一个类,在其他 ...