本文例程: https://files.cnblogs.com/files/heyang78/mediaCool_211010pm.rar

src/main/resources/templates  这个目录如果不存在就手动创建,它用于放置你要显示的网页

src/main/resources/static          这个目录如果不存在就手动创建,它用于放置你的网页用到的js、css、img等。

下面是我一个项目MediaCool的目录截图:

【SpringBoot/Thymeleaf】Thymeleaf目录设置

 然后,index.html是这样引用img、js和css的:

   <link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css">
    
    <link rel="stylesheet" type="text/css" href="stylesheets/theme.css">
    <link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">

    <script src="lib/jquery-1.7.2.min.js" type="text/javascript"></script>

由上可以看出,static目录不用明写,Thymeleaf知道去这个目录查找。

最后可以瞅一眼Index.html在Tomcat里表现的样子。

【SpringBoot/Thymeleaf】Thymeleaf目录设置

 END

相关文章:

  • 2021-07-23
  • 2021-06-19
  • 2021-10-03
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2018-06-01
  • 2021-11-16
  • 2017-12-19
相关资源
相似解决方案