默认的,SpringBoot会从两个地方查找静态资源:

  • classpath/static 的目录下
  • ServletContext 根目录下

一、classpath/static 的目录

在类路径下常见static目录,名称必须是static

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>静态资源访问方式一</title>
</head>
<body>
    静态资源访问方式一<br>
    <img alt="" src="data:images/java.png"> <!-- 不用写static-->
</body>
</html>

二、ServletContext 根目录下

在src/main中添加webapp,名称必须是webapp。

【使用篇二】SpringBoot访问静态资源(4)的更多相关文章

  1. 【SpringBoot】06.SpringBoot访问静态资源

    SpringBoot访问静态资源 1.SpringBoot从classpath/static的目录 目录名称必须是static 启动项目,访问http://localhost:8080/0101.jp ...

  2. Springboot访问静态资源&WebJars&图标&欢迎页面

    目录 概述 1.访问WebJar资源 2.访问静态资源 3.favicon.ico图标 4.欢迎页面 概述 使用Springboot进行web开发时,boot底层实际用的就是springmvc,项目中 ...

  3. springboot访问静态资源404

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...

  4. springboot(二 如何访问静态资源和使用模板引擎,以及 全局异常捕获)

    在我们开发Web应用的时候,需要引用大量的js.css.图片等静态资源. 默认配置 Spring Boot默认提供静态资源目录位置需置于classpath下,目录名需符合如下规则: /static / ...

  5. springboot访问静态资源遇到的坑

    开始是以这种结构进行的,结果页面上一篇红,访问的页面是这样的 最终找出来问题,虽然每次调整路径都不对,最终查看多种方法可以看到了: 增加: package com.example.demo.confi ...

  6. 02-04:springboot 访问静态资源

    1.SpringBoot从classpath/static的目录下:(目录名称必须叫static,可以理解为根目录为static) 2.servletContext根目录下,进行查找: 在src/ma ...

  7. Springboot访问静态资源

    转载 http://blog.csdn.net/catoop/article/details/50501706

  8. Spring Boot整合Servlet,Filter,Listener,访问静态资源

    目录 Spring Boot整合Servlet(两种方式) 第一种方式(通过注解扫描方式完成Servlet组件的注册): 第二种方式(通过方法完成Servlet组件的注册) Springboot整合F ...

  9. SpringBoot - 搭建静态资源存储服务器

    目录 前言 环境 实现效果 具体实现 文件上传 配置类 上传接口 上传实现 辅助类 实体 上传测试 文件访问 配置类 项目源码 前言 记录下SpringBoot下静态资源存储服务器的搭建. 环境 wi ...

随机推荐

  1. insertAdjacentHTML和insertAdjacentText的使用(在指定位置插入代码或者文字)

    insertAdjacentText方法与insertAdjacentHTML方法类似,只不过只能插入纯文本,参数相同.

  2. Python tempfile (临时文件)

    Python tempfile 大量临时数据放在内存中会占用大量资源,可以使用临时文件来进行储存 临时文件不用命名,且使用后会被自动删除 TemporaryFile 使用 TemporaryFile ...

  3. python socket编程腾讯云下报错[Errno 99] Cannot assign requested address的解决方式

    先写服务端server.py: import socket import time HOST = '172.17.xx.xx' #服务器的私网IP #HOST = 'localhost' PORT = ...

  4. NOIP模拟赛 拓展

    题目描述 Description \(φ\) 函数是数论中非常常用的函数.对于正整数 \(x\) ,\(φ(x)\) 表示不超过 \(x\) 的所有正整数与 \(x\) 互质的个数. 现在我们对它进行 ...

  5. NOIP模拟赛 迷路

    题目描述 Description \(FYH\) 在 \(ns\) 星系迷路了,情急之下,他找到了你.现在,解救 \(FYH\) 的重任就落在了你的肩上了. \(ns\) 星系有 \(n\) 颗星球, ...

  6. POJ2976Dropping tests(分数规划)

    传送门 题目大意:n个二元组a[i],b[i],去掉k个,求sigma a[i]/ sigma b[i]的最大值 代码: #include<iostream> #include<cs ...

  7. vue 路由跳转到本页面,ts 监听路由变化

    @Watch('$route') routechange(to: any, from: any) { //参数不相等 if (to.query.name!=from.query.name) { //t ...

  8. LeetCode 394:字符串解码 Decode String

    题目: 给定一个经过编码的字符串,返回它解码后的字符串. Given an encoded string, return its decoded string. 编码规则为: k[encoded_st ...

  9. CodeForce 176C Playing with Superglue

    Two players play a game. The game is played on a rectangular board with n × m squares. At the beginn ...

  10. java的Class<T>与类型信息

    类型是一个数据符号,代表着数据的内存布局和访问规则. default public <T> T xxxxx(Class<T> xclass) throws Exception ...