5ishare

万事开头难,昨天一直在构思用户权限管理系统怎么实现,实现哪些需求,采用什么技术等,也在网上百度了好多,计划使用SpringBoot + Mybatis + thymeleaf  + LayUI + Shiro等相关技术来实现,昨天新建了一个SpringBoot的项目,想着先使用LayUI实现左侧导航栏右侧上面Tab选项下面显示内容的系统首页,由于之前也没用过LayUI框架,昨天搞到2点多也没搞出来,今天偶然间找到了layTabPlus插件,该插件是一个layUI后台Tab布局框架的扩展插件,实现了Tab管理、刷新按钮、iframe优化等功能,非常好用,今天把layTabPlus插件集成到了SpringBoot项目中。

一、下载插件

需要下载两个插件,LayUI插件和layTabPlus插件,layTabPlus插件:https://gitee.com/Leytton/layTabPlus。

二、新建SpringBoot项目

新建项目时选择Web和thymeleaf 模块,这样项目的pom.xml中会引入spring-boot-starter-thymeleaf来自动集成thymeleaf。

三、将LayUI、layTabPlus拷贝到项目中

将在第一步下载的两个插件放到项目的资源包resources下,把layTabPlus插件中的index.html页面内容放到templates下,这里index.html用作了欢迎页面,所以使用了home.html。

四、创建Controller

这里在com.example.Controller包下创建了HomeController用来测试home.html。

package com.example.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/home")
public class HomeController {
    @RequestMapping(value = "/home",method = RequestMethod.GET)
    public String hello(Model model) {
        return "home";
    }
}
View Code

这里还不能忘了在main类中加上一句扫描包,不然会报404错误。

@ComponentScan(basePackages = {"com.example.*"})

五、启动项目,浏览器输入http://localhost:8080/home/home

六、小结

目前把首页做出来了,后续就是在此基础上集成Mybatis、日志等模块,实现页面的增删改查功能。

 

分类:

技术点:

相关文章: