zoukankan      html  css  js  c++  java
  • Springboot访问静态资源

      在Springboot项目中没用我们之前常规的web开发的WebContent(WebApp),它只有src目录

    在src/main/resources下面两个文件夹,static和templates。Springboot默认在static目录中存放静态页面,而templates中放动态页面

    1,static目录

      Springboot通过classpath/static目录访问静态资源,注意存放静态资源的目录名称必须是static  如:图片 HTML

    2,templates目录

      在Springboot中不推荐使用jsp作为视图层技术,而是默认使用Thymeleaf来做动态页面,Templates目录是存放Thymeleaf页面的

    3,其他静态资源目录 这里classpath是指main下的resources目录  springboot会按照以下的顺序依次查找静态资源

      classpath:/META-INF/resources/

      classpath:/resources/

      classpath:/static/

      classpath:/public/

    4,自定义静态资源目录  如果指定一个自定义目录时 其他的默认静态目录将不会被查找,如果需要多个静态资源目录用逗号隔开可以配置多个

      spring.resources.static-locations=classpath:/suibian/,classpath:/static/

  • 相关阅读:
    redis
    linux systemd
    分布式高可用架构演进
    c++ 多线程 信号量简单使用
    JAVA上传文件到FTP上
    JAVA字符串去掉html代码
    jQuery判断复选框是否勾选
    SpringBoot全局异常处理
    SpringBoot统一日志打印
    JAVA加解密之DES
  • 原文地址:https://www.cnblogs.com/yz-bky/p/12759912.html
Copyright © 2011-2022 走看看