Web开发.
springboot
- 自动装配
- 自动将环境配置好(执行导入相应的starter)
- 只需专注于业务代码
SpringBoot 配置了什么?能修改吗?可以修改什么?能不能扩展?
- xxxxAutoConfiguration… 向容器中自动配置组件
- xxxxProperties:自动装配类,装配配置文件中自动义的一些内容
WebMvcAutoConfiguration
WebMvcProperties
ResourceProperties
添加静态资源.
1、什么是webjars.
WebJars是将客户端(浏览器)资源(JavaScript,Css等)打成jar包文件,以对资源进行统一依赖管理。WebJars的jar包部署在Maven中央仓库上。
2、如何使用 webjars.
后端添加依赖(静态资源会加载到
classpath:/META-INF/resources/webjars/
下 )映射到/webjars/**
classpath:/META-INF/resource/**
,classpath:/resources/
,classpath:/static/
,classpath:/public/
会被映射到/**
优先级:resoures > static > public
localhost:port/** 静态资源都会到 后端以上目录中找
总结:.
在springboot中,我们可以使用以下方式处理静态资源
- webjars
localhost:port/webjars
- public,static,/**,resources
localhost:8080/
添加首页和图标定制.
index.html 可放置在
classpath:/resources/
classpath:/static/
classpath:/public/
classpath:/templates/
templates 目录下的所有页面,只能通过controller跳转
注意:所有的页面静态资源(本地url)都需要都需要thymeleaf托管 @{}