許可權管理系統之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、日誌等模組,實現頁面的增刪改查功能。