前端工程
我这边用一个基于react+datav组件信息展示屏项目
打包前端工程
npm run build
打包完成后会生成一个
build
文件夹,我们需要的就只有static
、favicon.ico
、index.html
SpringBoot工程
后端使用
thymeleaf
对 thymeleaf 还不熟悉的小伙伴可以先去了解下
文件复制
1. 在resources/static目录下新建一个 datav 的文件夹,把 打包好的 static下的所有文件以及favicon.ico放进去
2. 再将index.html放到templates下
3. 修改html文件引用
- thymeleaf 的html有自己专属的描述
- 对文件的引用是从static目录开始算起的,href和src前需要加上
th:
- 检查下css文件是否还有引用,都需要换成static下开始就完成了
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
4. 编写后端页面转发层
@Controller
@RequestMapping("/extra/datav")
public class ScreenDatavController{
@GetMapping("/index")
public String index(Model model) throws Exception {
return "extra/datav" + "/index";
}
}