在springboot中集成bootstrap

转载自:https://blog.csdn.net/sinat_24048051/article/details/77531834

首先导入依赖bootstrap与jquery:

  1. <!-- https://mvnrepository.com/artifact/org.webjars/bootstrap -->  
  2.         <!-- bootstrap -->  
  3.         <dependency>  
  4.             <groupId>org.webjars</groupId>  
  5.             <artifactId>bootstrap</artifactId>  
  6.             <version>3.3.5</version>  
  7.         </dependency>  
  8.         <dependency>  
  9.             <groupId>org.webjars</groupId>  
  10.             <artifactId>jquery</artifactId>  
  11.             <version>3.1.1</version>  
  12.         </dependency>  
然后在html文件中加入相应版本:
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <script src="webjars/jquery/3.1.1/jquery.min.js"></script>  
  5. <script src="webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>  
  6. <link rel="stylesheet" href="webjars/bootstrap/3.3.5/css/bootstrap.min.css" />    
  7. <meta charset="UTF-8">  
  8. <title>Insert title here</title>  
  9. </head>  
  10. <body>  
  11.     <h2>hello zhangyan</h2>  
  12.     <div class="container">  
  13.         <h2>Button</h2>  
  14.         <p>.btn 类是按钮的基本样式:</p>  
  15.         <button type="button" class="btn-warning">基本按钮</button>  
  16.     </div>  
  17. </body>  
  18. </html>  
关键的三句:

<script src="webjars/jquery/3.1.1/jquery.min.js"></script>
<script src="webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="webjars/bootstrap/3.3.5/css/bootstrap.min.css" />  

项目结构图:

然后就可以了。

不要在poi.xml中加build那些,尝试会有问题。

注:Spring Boot 会从以下路径寻找静态文件:

  • /META-INF/resources/
  • /resources/
  • /static/
  • /public/

Controller代码如下:

  1. @Controller  
  2. public class BackIndexController {  
  3.   
  4.     @RequestMapping(value = "/",method = RequestMethod.GET)  
  5.     public String index() {  
  6.           
  7.         return "backindex.html";  
  8.     }  
  9.       
  10. }  
需要加入后缀。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值