Recently, I have just completed a project. Due to the simple project, the leadership decision does not deposit into the database, as long as you write, you can do it too flexible, so think about it, decide this through XML To configure the way the menu is configured. Simply change the menu.xml file to dynamically change the structure of the menu. The dynamic changes of the secondary menu are currently implemented. This feature requires the following files, Menuvo.java This is the piping object of the menu, menuchildvo.java This is the piping object of the submenu. Menu.xml This is a configuration file, Menulist.java This is a class read the configuration file. Finally, write menu.jsp In this JSP through JavaScript, the menu tree structure is implemented. Through this menu function, I think it can consider the storage mode of data in the future, is it better to use the XML database. For example, some relatively stable data, the records of records can be stored in the format of the XML. This will save the trouble of the operation of the database, and the time of reading the database is also reduced. It is not difficult to operate the data, as long as the configuration file is changed, it is very applicable. ============================================================================================================================================================================================================= ====== Menu Object Class Menuvopublic Class Menuvo {Private String Menuid; Private String MenuName; Private String Menuhref; Private ArrayList Child;
Public void setment {this.Menuid = menuid;} public void setmenuname (String Menuname) {this.Menuname = menuname;}
Public String getMenuid ()} public string getmenuname () {returnimenuname;}
Public void setchild (arraylist child) {this.child = child;} public arraylist getChild () {return this.child;}
Public void setmenuhref (String Menuhref) {this.Menuhref = Menuhref;} public string getMenuhref () {Return this.Menuhref;}
} ================================================= menu object class public class MenuChildVO {private String menuhref = ""; private String menuname = ""; public void setMenuHref (String menuhref) {this.menuhref = menuhref;} public void setMenuName (String menuname) {this.menuname = menuname; PUBLIC STRING GETMENUHREF ()}} public string getmenuname ()}} this.Menuname;}}
==============================================
Menu.xml menu management configuration file, place below Web-Inf
XML Version = "1.0" encoding = "GB2312"?>