数码资讯
关于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
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。