一、配置application.yml文件下静态目录访问,index.html放在static目录下,自动获得地址http://localhost:8080访问。
spring:
application:
name: 项目名称
resources:
static-locations: classpath:/static/
二、配置freemarker引用
freemarker:
charset: utf-8
template-loader-path=classpath: /templates/
request-context-attribute: request
suffix: .ftl
cache: false
expose-request-attributes: true
expose-session-attributes: true
其中配置 request-context-attribute: request(可自定义名)之后,在freemarker模板文件*.ftl里可以引用为 ${request.contextPath} 来获取相对路径地址。
三、将bootstrap目录拷贝到static目录下,模板页面引用bootstrap。
<link href="${request.contextPath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="${request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
四、以上步骤完成后,如果访问后无法出现bootstrap效果的话,按以下步骤重新编译。
然后查看target目录里有没有bootstrap生成
按以上步骤成功引入bootstrap效果