zoukankan      html  css  js  c++  java
  • 关于SpringBoot下template文件夹下html页面访问的一些问题

    • springboot整合了springmvc的拦截功能。拦截了所有的请求。默认放行的资源是:resources/static/ 目录下所有静态资源。(不走controller控制器就能直接访问到资源)。
      • html页面如果放在resources/templates目录下,则需要走controller控制器,controller放行,允许该资源访问,该资源才能被访问到。否则就会报404错误(它不可以直接被访问)。

    • springboot项目中templates包下的html代码无法引入static下的静态文件。
      • .properties中添加:spring.mvc.static-path-pattern=/static/**
    • 关于springboot中thymeleaf的配置:
      spring.mvc.static-path-pattern=/static/**
      spring.thymeleaf.servlet.content-type=text/html
      spring.thymeleaf.mode=HTML
      spring.thymeleaf.cache=false
      spring.thymeleaf.prefix=classpath:/templates/
      spring.thymeleaf.suffix=.html
  • 相关阅读:
    3.2.8.1 打印与否
    3.2.8 sed 的运作
    3.2.7.1 替换细节
    3.2.7 基本用法
    3.2.6 在文本文件里进行替换
    3.2.5 程序与正则表达式
    pgm2
    pgm6
    pgm7
    pgm8
  • 原文地址:https://www.cnblogs.com/LJing21/p/11477821.html
Copyright © 2011-2022 走看看