SpringBoot学习使用(一)访问html页面

创建springboot配置文件application.roperties

在创建resouces目录下创建application.properties,创建完成后会出现一个绿叶图标

打开application.properties,添加如下配置:

spring.mvc.view.prefix=classpath:/templates/
spring.mvc.view.suffix=.html

优化

1.依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

application.properties是否加了配置:

#thymelea模板配置
spring.thymeleaf.prefix=classpath:/templates/
# templates中的所有文件后缀名
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.cache=false

检查.html文件是否放在了resource–>templates文件夹路径下,以及css,js等的外部包是否放在了resource–>static文件夹路径下。

html文件里引入方式为:

<script th:src="@{/js/jquery.js}"  type="text/javascript"></script>

从static位置后开始写,如果想静态编辑一起引入,可以:

<script th:src="@{/js/jquery.js}" src="../static/js/jquery.js" type="text/javascript"></script>

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值