To put it bluntly, we will introduce the main functions of the code I wrote: This menu program can be used only by configuring XML, and one or more permissions can be set for each menu item during configuration, easy to use. You can download it as soon as possible. I uploaded it to my resources.
Code Overview:
XML file:
<? Xml version = "1.0" encoding = "GB2312"?>
<MenuConfig>
<Displayers>
<Displayer name = "ListMenu" type = "wp.com"/>
</Displayers>
<! -- Roles indicates user permissions. Multiple permissions are separated by commas. -->
<Menus>
<Menu name = "yonghuguanli" title = "user management">
<Item name = "zjyh" target = "main" title = "Add user 1" location = "aa" roles = "mm"/>
<Item name = "scyh" target = "main" title = "delete user 2" location = "bb" roles = "xx, dd"/>
<Item name = "zjyh" target = "main" title = "Add user 3" location = "aa" roles = "xx"/>
<Item name = "scyh" target = "main" title = "delete user 4" location = "bb" roles = "xx, cc"/>
</Menu>
<Menu name = "shebeiguanli" title = "device management">
<Item name = "zjsb" target = "main" title = "Add a device" location = "#" roles = "cc"/>
<Item name = "scsb" target = "main" title = "delete a device" location = "#" roles = "xx"/>
</Menu>
....................
..........................
For example, if user A has the dd and cc permissions, only two corresponding menus are displayed.
If the user does not have the permission to include sub-menus, the total menu is not displayed.
Call method:
......
CreatMenu cm = new creatMenu ();
String source = cm. readDom ("dd, cc"); // user permissions
.......
Menu Image style:
</