<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
double randomNum = Math.random();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="UTF-8">
<title>站群管理系统 - 欢迎来到站群管理系统</title>
<link href="<%=path%>/resources/css/main.css" rel="stylesheet" type="text/css" />
<jsp:include page="/jsp/common/jquery-eayui_include.jsp" />
<style>
.zx{ background:url(resources/images/ann.png) no-repeat -43px 0; height:33px; width:33px; display:block; float:right;}
.zx:hover{ background:url(resources/images/ann.png) no-repeat -43px -37px;}
.xgmm{ background:url(resources/images/ann.png) no-repeat 0 0; height:33px; width:33px; display:block; float:right;}
.xgmm:hover{ background:url(resources/images/ann.png) no-repeat 0 -37px;}
</style>
<script type="text/javascript">
$(document.body).ready(function(){
$("#gnbs").tree({
url:"<%=path%>/getGnbs?_<%=randomNum%>",
animate:true,
lines: true,
onSelect:function(node){
var node=$("#gnbs").tree('getSelected');
}
});
});
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false" style=" height:76px; background:url(resources/images/index_top_01.jpg) no-repeat left top #95b8e7;">
<div style=" float:right; width:471px; background:url(resources/images/index_top_03.jpg) no-repeat right top; height:36px; text-align:right; padding-right:30px; padding-top:40px; color:#ffffff;">
<a class="zx" title="注销" href="<%=path%>/logout"></a>
<!-- <a class="xgmm" style=" margin-right:10px;" title="修改密码" href="<%=path%>/logout"></a>-->
<span style=" float:right; line-height:33px; margin-right:10px;">欢迎 ${sessionScope.CURRENT_USER.xm} !</span></div>
</div>
<div data-options="region:'west',split:true,title:'菜单栏'" style="width:200px;padding:10px;">
<!-- <div class="easyui-accordion" data-options="fit:true,border:false" id="wnav">-->
<ul id="gnbs" class="easyui-tree"></ul>
<!-- </div>-->
</div>
<div data-options="region:'east',split:true,collapsed:true,title:'常用工具'" style="width:100px;padding:10px; ">更多...</div>
<div data-options="region:'south',border:false" style="height:50px;background:#95b8e7;padding:10px; color:#ffffff; text-align:center;"></div>
<div data-options="region:'center'">
<div class="easyui-tabs" data-options="fit:true,border:false,plain:true" id="tt_tabs">
<div title="首页" data-options="href:'<%=path%>/jsp/common/main/_content.jsp'" style="padding:10px"></div>
</div>
</div>
<script type="text/javascript">
//添加菜单事件
var tt_tabs = $('#tt_tabs');
$('#gnbs').tree({
onDblClick: function (node){
if (tt_tabs.tabs('exists', node.gnmc)){//如果tab已经存在,则选中并刷新该tab
tt_tabs.tabs('select', node.gnmc);
refreshTab({tabTitle:node.gnmc,url:node.fwlj});
}else {
var content="";
content = '<iframe scrolling="no" frameborder="0" src="'+node.fwlj+'" style="width:100%;height:100%;"></iframe>';
$('#tt_tabs').tabs('add',{
title: node.gnmc,
content: content,
closable: true
});
}
}
});
/**
* 刷新tab
* @cfg
*example: {tabTitle:'tabTitle',url:'refreshUrl'}
*如果tabTitle为空,则默认刷新当前选中的tab
*如果url为空,则默认以原来的url进行reload
*/
function refreshTab(cfg){
var refresh_tab = cfg.tabTitle?$('#tt_tabs').tabs('getTab',cfg.tabTitle):$('#tt_tabs').tabs('getSelected');
if(refresh_tab && refresh_tab.find('iframe').length > 0){
var _refresh_ifram = refresh_tab.find('iframe')[0];
var refresh_url = cfg.url?cfg.url:_refresh_ifram.src;
//_refresh_ifram.src = refresh_url;
_refresh_ifram.contentWindow.location.href=refresh_url;
}
}
</script>
</body>
</html>
出错的问题是因为我把那个tree的js写到了body里面,放到head里面就可以了,上面是正确的用法