SpringMVC+EasyUI實現頁面左側導航菜單功能
1. 效果圖展示

2. 工程目錄結構
注意: webapp下的resources目錄放置easyui和js(jQuery文件是另外的)
3. 代碼
index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>學生成績管理系統 管理員后臺</title>
<link rel="stylesheet" type="text/css" href="/resources/easyui/css/default.css" rel="external nofollow" rel="external nofollow" />
<link rel="stylesheet" type="text/css" href="/resources/easyui/themes/default/easyui.css" rel="external nofollow" rel="external nofollow" >
<link rel="stylesheet" type="text/css" href="/resources/easyui/themes/icon.css" rel="external nofollow" rel="external nofollow" >
<%--以下三個js文件導入順序不要調整!!--%>
<script type="text/javascript" src="/resources/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="/resources/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/resources/easyui/js/outlook2.js"></script>
<script type="text/javascript">
var _menus = {
"menus": [
{
"menuid": "1", "icon": "", "menuname": "成績統計分析",
"menus": [
{
"menuid": "11",
"menuname": "考試列表",
"icon": "icon-exam",
"url": "ExamServlet?method=toExamListView"
}
]
},
{
"menuid": "2", "icon": "", "menuname": "學生信息管理",
"menus": [
{
"menuid": "21",
"menuname": "學生列表",
"icon": "icon-user-student",
"url": "StudentServlet?method=toStudentListView"
},
]
},
{
"menuid": "3", "icon": "", "menuname": "教師信息管理",
"menus": [
{
"menuid": "31",
"menuname": "教師列表",
"icon": "icon-user-teacher",
"url": "TeacherServlet?method=toTeacherListView"
},
]
},
{
"menuid": "4", "icon": "", "menuname": "基礎信息管理",
"menus": [
{
"menuid": "41",
"menuname": "年級列表",
"icon": "icon-world",
"url": "GradeServlet?method=toGradeListView"
},
{
"menuid": "42",
"menuname": "班級列表",
"icon": "icon-house",
"url": "ClazzServlet?method=toClazzListView"
},
{
"menuid": "43",
"menuname": "課程列表",
"icon": "icon-book-open",
"url": "CourseServlet?method=toCourseListView"
}
]
},
{
"menuid": "5", "icon": "", "menuname": "系統管理",
"menus": [
{
"menuid": "51",
"menuname": "系統設置",
"icon": "icon-set",
"url": "SystemServlet?method=toAdminPersonalView"
},
]
}
]
};
</script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<div region="north" split="true" border="false" style="overflow: hidden; height: 30px;
line-height: 20px;color: #fff; font-family: Verdana, 微軟雅黑,黑體"></div>
<div data-options="region:'south',title:'South Title',split:true" style="height:100px;"></div>
<div data-options="region:'west',title:'導航菜單',split:true" style="width:200px;">
<div id="nav" class="easyui-accordion" fit="true" border="false">
</div>
</div>
<div data-options="region:'center',title:'center title'" style="padding:5px;background:#eee;"></div>
</body>
</html>
springmvc.xml配置靜態(tài)資源
<!--靜態(tài)資源--> <mvc:resources mapping="/resources/**" location="/resources/"/>
注意:
1. EasyUI和JQuery文件是放在webapp/resources目錄下的, 需要把 jquery-1.7.2.js也引進去.
2. jsp文件中引入EasyUI的css和js文件的順序如下, 不要隨意調整!!!
<link rel="stylesheet" type="text/css" href="/resources/easyui/css/default.css" rel="external nofollow" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="/resources/easyui/themes/default/easyui.css" rel="external nofollow" rel="external nofollow" > <link rel="stylesheet" type="text/css" href="/resources/easyui/themes/icon.css" rel="external nofollow" rel="external nofollow" > <%--以下三個js文件導入順序不要調整!!--%> <script type="text/javascript" src="/resources/js/jquery-1.7.2.js"></script> <script type="text/javascript" src="/resources/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="/resources/easyui/js/outlook2.js"></script>
3. springMVC的靜態(tài)資源配置是針對resources目錄下所有文件的, 所以之后的圖片等靜態(tài)資源文件也直接放在resources目錄下即可.
4. 導航菜單是在以下id為nav的div里顯示的
<div data-options="region:'west',title:'導航菜單',split:true" style="width:200px;"> <div id="nav" class="easyui-accordion" fit="true" border="false"> </div> </div>
該div的id屬性一定要是 nav, 試過其它的都沒有效果.
總結
以上所述是小編給大家介紹的SpringMVC+EasyUI實現頁面左側導航菜單功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!
相關文章
解析Java的Spring框架的BeanPostProcessor發(fā)布處理器
這篇文章主要介紹了Java的Spring框架的BeanPostProcessor發(fā)布處理器,Spring是Java的SSH三大web開發(fā)框架之一,需要的朋友可以參考下2015-12-12
IDEA2023創(chuàng)建MavenWeb項目并搭建Servlet工程的全過程
Maven提供了大量不同類型的Archetype模板,通過它們可以幫助用戶快速的創(chuàng)建Java項目,這篇文章主要給大家介紹了關于IDEA2023創(chuàng)建MavenWeb項目并搭建Servlet工程的相關資料,需要的朋友可以參考下2023-10-10
idea項目debug模式啟動,斷點失效,斷點紅點內無對勾問題及解決
這篇文章主要介紹了idea項目debug模式啟動,斷點失效,斷點紅點內無對勾問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-10-10
springboot 如何通過SpringTemplateEngine渲染html
通過Spring的Thymeleaf模板引擎可以實現將模板渲染為HTML字符串,而不是直接輸出到瀏覽器,這樣可以對渲染后的字符串進行其他操作,如保存到文件或進一步處理,感興趣的朋友跟隨小編一起看看吧2024-10-10
SpringBoot默認包掃描機制及@ComponentScan指定掃描路徑詳解
這篇文章主要介紹了SpringBoot默認包掃描機制及@ComponentScan指定掃描路徑詳解,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-11-11
解決Spring Cloud中Feign/Ribbon第一次請求失敗的方法
這篇文章主要給大家介紹了關于解決Spring Cloud中Feign/Ribbon第一次請求失敗的方法,文中給出了三種解決的方法,大家可以根據需要選擇對應的方法,需要的朋友們下面來一起看看吧。2017-02-02

