easyui(tree后台工作)

一、servlet

package com.zking.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.zking.biz.IModuleBiz;
import com.zking.biz.ModuleBiz;
import com.zking.entity.Module;

@WebServlet("/IndexServlet")
public class IndexServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//三个编码方式
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		//拿到out
		PrintWriter out = response.getWriter();
		//拿biz
		IModuleBiz imb=new ModuleBiz();
		List<Module> ls=imb.getAllById(-1);
		String str=JSON.toJSONString(ls);
		out.write(str);
		out.flush();
		out.close();
	}

}

主界面代码:

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- 引入head -->
<%@ include file="common/head.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	$(function() {
		$('#myTree').tree({
			url : ctx + '/IndexServlet',//请求地址
			animate : true,//折叠或者展开的时候是否显示动画效果
			onDblClick : function(node) {
				//alert(node.text+"   "+node.id+"   "+node.state);  // 在用户双击的时候提示
				//alert(node.iconCls);//图标
				//拿到对应的后代节点的集合
				var cs=$('#myTree').tree('getChildren',node.target);
				//alert(cs.length);
				if(cs.length==0){
					//判断是否存在
					var f = $('#myTab').tabs('exists',node.text);
					//alert(f);
					if(!f){//说明不存在
						//新打开一个选项卡(tab页) iconCls:'icon-ok' 
						$('#myTab').tabs('add',{    
						    title:node.text, // 标题  
						    content:'<iframe frameborder="0" width="99%" height="99%" src="'+node.url+'"></iframe>',  //内容
						    closable:true,  //是否可关闭
						    iconCls:node.iconCls
						});  
					}
					else{//说明存在 让其对应选中
						$('#myTab').tabs('select',node.text);
					}
				}
				
			}
		});
	})
</script>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',split:true"
		style="height: 100px; text-align: center;">
		<h1>书籍管理后台</h1>
	</div>
	<div data-options="region:'south',split:true"
		style="height: 70px; text-align: center;">
		<b>&copy;玉渊工作室,未经允许不可随意使用</b>
	</div>
	<div data-options="region:'west',title:'功能导航',split:true"
		style="width: 200px;">
		<!-- 左侧tree控件 -->
		<ul id="myTree" class="easyui-tree">

		</ul>

	</div>
	<div data-options="region:'center'"
		style="padding: 5px; background: #fff;">
		
		<!-- 中间的tab控件 -->
		<div id="myTab" class="easyui-tabs" style="width:100%; height: 100%;">
			<div data-options="iconCls:'icon-application-home'" title="首页" style="padding: 20px; display: none;">
				<img src="images/lb1.png" width="100%" height="100%">
			</div>
		</div>
	</div>
</body>
</html>

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值