@ResponseBody
public List
Menu menu = new Menu();
if(id !=null && id > 0){
menu.setParentId(id);
}else{
menu.setParentId(0);
}
return menuService.query(menu);
}
然后在控制器中具体处理请求
public List
MenuExample example = new MenuExample();
MenuExample.Criteria criteria = example.createCriteria();
if(menu!=null){
if(menu.getParentId()!=null ){
// 根据父菜单编号查询
criteria.andParentIdEqualTo(menu.getParentId());
}else{
criteria.andParentIdEqualTo(0);
}
}
return menuMapper.selectByExample(example);
}
home界面的主要代码如下:
style="height: 100px;background: url(img/logo.png) no-repeat 0% 50%; ">
百战程序员 |
<shiro:principal property=“username”></shiro:principal> |
style=“width: 180px;”>
style=“padding: 0px; background: #eee;”>
欢迎光临
加载导航菜单的核心代码:
// 加载菜单数据 state:closed是关键
$(function(){
// 动态添加菜单
$(“#tt”).tree({
url: “/sys/menu/getNode”,
onClick: function(node){
if(node.url != null && node.url != ‘’ ){
// 打开一个新的窗口
goTabs(node.url+“/go”,node.text);
}
}
});
});
// 点击子菜单开的一个新窗口的代码
function goTabs(path,title){
// 动态添加一个标签页
var isSelect = $(“#tabs”).tabs(‘exists’, title);
// 添加一个新的标签页面板(tab panel)
if(isSelect){
$(“#tabs”).tabs(‘select’, title);
return;
}else{
$(‘#tabs’).tabs(‘add’,{
title:title,
content:‘’,
closable:true,
//刷新按钮
tools: [{
iconCls: ‘icon-mini-refresh’,
handler: function(){
var currentTab = $(‘#tabs’).tabs(‘getSelected’);
RefreshTab(currentTab);
}
}]
});
}
}
//刷新当前标签Tabs
function RefreshTab(currentTab) {
var url = $(currentTab.panel(‘options’)).attr(‘href’);
$(‘#tabs’).tabs(‘update’, {
tab: currentTab,