權限管理系統之SpringBoot集成LayUI實現后台管理首頁


萬事開頭難,昨天一直在構思用戶權限管理系統怎么實現,實現哪些需求,采用什么技術等,也在網上百度了好多,計划使用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、日志等模塊,實現頁面的增刪改查功能。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM