项目搭建
-
准备数据库
-
通过官网Spring Initializr创建项目,引入依赖有spring web、MyBatisPlus、thymeleaf、mysql驱动、lombok、spring test
-
idea(社区版)导入
-
编写配置文件application.yml
-
创建包结构
-
页面跳转类PageController
package com.example.travel.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class PageController {
// 访问后台页面
@RequestMapping("/backstage/{page}")
public String showPageBackstage(@PathVariable String page){
return "/backstage/"+page;
}
// 访问前台页面
@RequestMapping("/frontdesk/{page}")
public String showPageFrontdesk(@PathVariable String page){
return "/frontdesk/"+page;
}
// 忽略访问项目logo
@RequestMapping("favicon.ico")
@ResponseBody
void returnNoFavicon() {}
}
- 运行测试
- AdminLTE官网下载后放在静态资源
- 要用什么直接从static放到template,然后修改…
- 运行测试,需要重新加载静态资源
- 添加thymeleaf命名空间,后台首页改好框架,接口名字
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
改后如图
- (thymeleaf)提取后台统一模板,方面其他页面引入
引入后重新运行