springboot 整合springmvc
导包
- 在pom.xml文件中导入SpringBoot web启动的starter
- 在pom.xml中引入thymeleaf的starter
== 注:如果牵涉到页面跳转,必须先集成thymeleaf,否则会报404错误==
引入静态资源
SpringBoot以 webjars jar包的方式引入静态资源
webjars 官网:https://www.webjars.com/ 我们可以在官网中找到对应的静态资源依赖,配置到pom.xml中 如图:
常规的静态资源路径
SpringBoot默认的静态资源的文件夹(默认不拦截)。静态资源文件夹下的内容可以从浏览器中直接访问
“classpath:/META-INF/resources/”,
“classpath:/resources/”,
“classpath:/static/”,
“classpath:/public/”
“/”:(注:此处指的是项目根路径,而不是类路径)
SpringBoot项目的欢迎页设置
欢迎页 : 静态资源文件夹下的所有index.html页面。