zoukankan      html  css  js  c++  java
  • 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



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

  • 相关阅读:
    Nucleus 的网络部分
    VS2005中TextBox的ReadOnly属性(转贴)
    VS2005中TextBox的ReadOnly属性导致的问题
    外部中断
    Linux操作系统文件链接问题
    IIS 服务不能自动启动
    转贴:[C++]static用法
    串口测试的一些体会
    字符串的两种声明方式
    Tornado 2.2 中vxsim出问题的解决方法
  • 原文地址:https://www.cnblogs.com/duyinqiang/p/5696523.html
Copyright © 2011-2022 走看看