1. Preparatory work
(1) JQuery Easy UI
(2) MySQL data
(3) Eclipse development environment, etc.
2. Development front-end
<body class= "Easyui-layout" >
<div data-options= "region: ' North ', Title: ' Header ', split:true,noheader:true" style= "Height:60px;background: #666 ;" >
<div class= "logo" > Website background service Management </div>
<div class= "Logout" > Hello, ssss | <a href= "# #" > Exit </a></div>
</div>
<div data-options= "region: ' South ', Title: ' Footer ', split:true,noheader:true" style= "height:35px;line-height : 30px;text-align:center; " >
<span> this site by the company's technical team for technical support! </span>
</div>
<div data-options= "region: ' West ', title: ' Navigation ', Split:true,iconcls: ' Icon-world '" style= "width:180px;padding:10px;" >
<ul id= "NAV" ></ul>
</div>
<div data-options= "region: ' Center '" style= "Overflow:hidden;" >
<div id= "Tabs" >
<div title= "Start Page" iconcls= "Icon-house" style= "padding:10px 10px;display:block;" >
Welcome to the Backstage management system!
</div>
</div>
</div>
</body>
JS section
$ (function () {
$ (' #nav '). Tree ({
URL: ' Navmenu.do?code=1&id=0 ',
Lines:true,
Onclick:function (node) {
if (Node.url) {
if ($ (' #tabs '). Tabs (' exists ', Node.text)) {
$ (' #tabs '). Tabs (' select ', Node.text);
} else {
$ (' #tabs '). Tabs (' Add ', {
Title:node.text,
IconCls:node.iconCls,
Closable:true,
Href:node.url + '. Do ',
});
}
}
}
});
$ (' #tabs '). Tabs ({
Fit:true,
Border:false,
});
});
3. Writing Background code
(1) Create a database table
(2) Writing entity classes
(3) Writing database traversal data method
where DBHelper and CRS classes are omitted, they are all encapsulated in the database JDBC
public class Navmenudaoimpl extends DBHelper implements navmenudao{
@Override
Public list<navmenu> findallnavmenu (int id) {
list<navmenu> list = new arraylist<navmenu> ();
String sql = "SELECT * from Nav_menu WHERE nid =?";
Object []obj ={id};
CRS CRS = executeQuery (sql, obj);
ResultSet rs = Crs.getrs ();
try {
while (Rs.next ()) {
List.add (New Navmenu (Rs.getint (1), rs.getstring (2), rs.getstring (3), rs.getstring (4), rs.getstring (5), Findallnavmenubyid (Rs.getint (1)));
}
}catch (SQLException e) {
E.printstacktrace ();
}finally{
Closesource (CRS);
}
return list;
}
Public list<navmenu> Findallnavmenubyid (int id) {
list<navmenu> list = new arraylist<navmenu> ();
String sql = "SELECT * from Nav_menu WHERE nid =?";
Object []obj ={id};
CRS CRS = executeQuery (sql, obj);
ResultSet rs = Crs.getrs ();
try {
while (Rs.next ()) {
List.add (New Navmenu (Rs.getint (1), rs.getstring (2), rs.getstring (3), rs.getstring (4), rs.getstring (5)));
}
}catch (SQLException e) {
E.printstacktrace ();
}finally{
Closesource (CRS);
}
return list;
}
}
(4) Writing and configuring Servlets
Xml
5. Test results
JQUERY Easy UI +tree +servlet Display Menu Example