• spring-boot 加载本地静态资源文件路径配置


    1.spring boot默认加载文件的路径是 
    /META-INF/resources/ 
    /resources/ 
    /static/ 
    /public/ 
    这些目录下面, 当然我们也可以从spring boot源码也可以看到 
    Java代码  收藏代码
    1. private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {  
    2.         "classpath:/META-INF/resources/""classpath:/resources/",  
    3.         "classpath:/static/""classpath:/public/" };  

    所有本地的静态资源都配置在了classpath下面了, 而非在webapp下了 

    2. 
    Html代码  收藏代码
    1. <%@ page language="java" contentType="text/html; charset=utf-8"  
    2.     pageEncoding="utf-8"%>  
    3. <!DOCTYPE html>  
    4. <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>  
    5. <html lang="zh-cn">  
    6. <head>  
    7. <meta charset="utf-8">  
    8. <meta http-equiv="X-UA-Compatible" content="IE=edge">  
    9. <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    10. <meta name="description" content="">  
    11. <meta name="author" content="">  
    12.   
    13. <title>用户登录</title>  
    14. </head>  
    15. <!-- CSS件 -->  
    16. <link rel="stylesheet" href="/css/bootstrap.min.css">  
    17. <link rel="stylesheet" href="/css/login.css">  
    18. <body>  
    19.     <div class="container">  
    20.         <form class="form-signin">  
    21.             <h2 class="form-signin-heading">Please sign in</h2>  
    22.             <input type="text" class="form-control" placeholder="Email address" required autofocus>   
    23.             <input type="password" class="form-control" placeholder="Password" required>   
    24.             <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>  
    25.         </form>  
    26.     </div>  
    27.   
    28.     <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>  
    29.     <script src="/js/bootstrap.min.js"></script>  
    30. </body>  
    31. </html>  

    3.目录结构详见附件 

    项目地址https://github.com/leelance/spring-boot-all



    技术分享,关注茶爸爸微信公众号

  • 相关阅读:
    hdu6514 // 二维差分 二维前缀和 基本容斥 压维
    【模板】欧拉函数 & 欧拉筛
    并查集模板 hdu1703
    大数 gcd
    hdu1087 dp
    洛谷p1306 斐波那契公约数
    hdu6814 Tetrahedron 线性求逆元 + 快速幂求逆元
    hdu6867 Tree // DFS
    hdu6869 Slime and Stones // 威佐夫博弈&#183;改
    Python实现EXCEL表格的排序功能
  • 原文地址:https://www.cnblogs.com/duyinqiang/p/5696523.html
Copyright © 2020-2023  润新知