structs中dtree的应用
经过一段时间的研究,终于把structs _menu 给换掉了,因为我感觉这个有点麻烦,应用有事费事,现在是,时间经济,越快,完成,就越快取得经济效益.
我用的myeclipse 6.1 + sdk6.0做的,以下,是数据结构表.
|
用myeclipse 生成vo,po 以及操作办法,最后,用structs 起草了一个action,在action事件事,调用了两个事件,一个事件,
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
FunctionsDAO functiondao = new FunctionsDAO();
List list=functiondao.findAll();
request.setAttribute("treeList",list);
// request.setAttribute("list", list);
//System.out.println(list.size());
return mapping.findForward("findsuc");
}
把值传到了页面.注意,是自动生成的vo ,po 方法.
这是页面.
<%@ page language="java" pageEncoding="gb2312"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>Destroydrop » Javascripts » Tree</title>
<link rel="StyleSheet" href="dtree.css" type="text/css" />
<script type="text/javascript" src="js/dtree.js"></script>
</head>
<body>
<div class="dtree">
<p><a href="javascript: tree.openAll();">全部打开</a> | <a href="javascript: tree.closeAll();">全部关闭</a></p>
<script type='text/javascript'>
tree = new dTree('d');
tree.config.folderLinks=false;
tree.config.useCookies=false;
<logic:iterate id="functionsForm" name="treeList" scope="request">
tree.add("<bean:write name="functionsForm" property="id"/>","<bean:write
name="functionsForm" property="pid"/>","<bean:write name="functionsForm"
property="name"/>","<bean:write name="functionsForm"
property="url"/>","<bean:write name="functionsForm"
property="title"/>","<bean:write name="functionsForm"
property="target"/>","<bean:write name="functionsForm" property="icon"/>");
</logic:iterate>
document.write(tree);
</script>
</div>
</body>
</html>
以下,strcts 架构
<action path="/findtree" type="org.longxin.struts.action.Functions1Action">
<forward name="findsuc" path="/example021.jsp"></forward>
</action>
加上就好使.