项目--thymeleaf修改项目资源路径

1.创建项目时选择web和thymeleaf,删除不需要的文件(选择文件,按delete)

2.js,css,img放在resource中的static中,页面放在resources中的templates

3.controller中的get请求方式

package com.cc.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class ProviderController {

    //@RequestMapping(value="/providers",method= RequestMethod.GET)
    @GetMapping("/providers")
    public String list(){
      return "provider/list";
    }
}

4.热部署依赖和配置文件

    <!--热部署配置-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
spring.thymeleaf.cache=false

5.引入css,图片引入,引入webjars(先pom依赖包)

 <link rel="stylesheet" th:href="@{/css/public.css}" />
      <a href="view.html"><img th:src="@{/img/read.png}"  alt="查看" title="查看"/></a>
  <!--引入 jquery webjars-->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.3.1</version>
        </dependency>
<script th:src="@{/webjars/jquery/3.3.1/jquery.js}" src="../js/jquery.js"></script>
<script th:src="@{/js/js.js}"  src="../js/js.js"></script>

访问页中,查看页面源代码,点击jquery链接出现代码,则说明webjars成功

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值