3.异步加载jsp处理页面
<%@ page language="java" import="java.util.*,cn.com.hgjf.cms.dao.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
String op=request.getParameter("op");
String id=request.getParameter("id");
MenuDao md=new MenuDao();
if(op.equals("init"))
{
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control","no-cache");
//System.out.println(md.createDHTMLXML("0"));
response.getWriter().print(md.createDHTMLXML2("0"));//dhtmlxTree方式
}
else
{
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control","no-cache");
response.getWriter().print(md.createDHTMLXML2(id));//dhtmlxTree方式
}
%>
4.dwr后台处理java类
/**
*@author:高清宝
*<p>Email:yyk1504@163.com</p>
*<p>创建日期:2008-9-9 上午11:59:34</p>
*/
package cn.com.hgjf.cms.serverlet;
import java.util.ArrayList;
import cn.com.hgjf.cms.dao.MenuDao;
public class MenuServerlet
{
MenuDao md=new MenuDao();
public ArrayList getChirdid(String parentid,String tableid,String show)
{
//System.out.println(parentid);
ArrayList al=md.getChirldMenu(parentid,tableid,show);
return al;
}
public ArrayList getMenuInfo(String id)
{
//System.out.println(parentid);
ArrayList al=md.getMenuInfoById(id);
return al;
}
/**
* <p>修改菜单</p>
* @return
*/
public String modify(String id,String name,String link,String orders,String is_show,String is_quick)
{
System.out.println(id);
boolean bl=md.edit(id, name, link, orders, is_show, is_quick);
if(bl==true)
{
return "修改成功";
}
else
{
return "修改失败";
}
}
/**
* <p>删除菜单</p>
*/
public String deleteAll(String id)
{
boolean bl=md.delete(id);
if(bl==true)
{
return "删除节点成功!";
}
else
{
return "删除节点失败!";
}
}
/**
* <p>删除菜单</p>
*/
public String Add(String id,String name,String link,String orders,String is_show,String is_quick)
{
int parentid=-1;
int chirldid=0;
int max_id=md.getMaxId();
if(id.equals("root"))//顶级节点
{
parentid=-1;
chirldid=md.getChirldIdById();
}
else
{
parentid=Integer.valueOf(id);
chirldid=-1;
}
boolean bl=md.add(parentid, chirldid, name, link, orders, is_show, is_quick,max_id);
if(bl==true)
{
return "true;"+max_id+";"+parentid+";"+chirldid;//"新增【"+name+"】节点成功!";
}
else
{
return "false;"+max_id+";"+parentid+";"+chirldid;//"新增【"+name+"】节点失败!";
}
}
public int getChirldId()
{
return md.getChirldIdById();
}
}
5.数据库脚本
USE [cms]
GO
/****** 对象: Table [dbo].[cms_menu] 脚本日期: 10/30/2008 15:05:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[cms_menu](
[id] [int] NOT NULL,
[parent_id] [int] NOT NULL CONSTRAINT [DF_cms_menu_parent_id] DEFAULT ((-1)),
[chirld_id] [int] NOT NULL CONSTRAINT [DF_cms_menu_chirld_id] DEFAULT ((0)),
[name] [varchar](100) COLLATE Chinese_PRC_CI_AS NULL,
[link] [varchar](100) COLLATE Chinese_PRC_CI_AS NULL CONSTRAINT [DF_cms_menu_link] DEFAULT ('#'),
[orders] [int] NULL CONSTRAINT [DF_cms_menu_order] DEFAULT ((1)),
[is_show] [int] NULL CONSTRAINT [DF_cms_menu_is_ahow] DEFAULT ((0)),
[is_quick] [int] NULL CONSTRAINT [DF_cms_menu_is_quick] DEFAULT ((1)),
CONSTRAINT [PK_cms_menu] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0显示,1不显示' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'cms_menu', @level2type=N'COLUMN', @level2name=N'is_show'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0作为快速通道,1不作为快速通道' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'cms_menu', @level2type=N'COLUMN', @level2name=N'is_quick'
demo下载