JQUERY Easy UI +tree +servlet Display Menu Example

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.