1.场景还原
由于公司项目是springboot构建的,访问静态资源必须是首要的考虑;但是springboot访问静态资源跟ssm中有些不一样的地方, 今天笔者就讲解一下在springboot工程中如何加载静态资源。
2.实现方案
方案①:直接地址栏访问
在工程的resources目录下新建static目录,将待访问的静态资源放进去
方案②:通过后台controller实现前端页面跳转
1>在pom.xml中加入velocity依赖( 模板引擎)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
</dependency>
2>在application.properities配置
spring.velocity.suffix=.html
3.在resources新建static,templates目录
static目录放静态文件(js,css,image之类),templates放模板文件(html,jsp)