struts2.2.3标签<s:tree>

无意中看到了struts2的标签能做树形结构,于是便去做了一下,发现了问题还真不少,先让我归纳一下,问题主要如下:

第一、<s:tree>标签不是struts-tags里面的标签,而是struts-dojo-tags里面的标签,使用的人在声明标签的时候记得是使用<%@ taglib prefix="s" uri="/struts-dojo-tags"%>的方法。当然咯,要引入struts2-dojo-plugin-2.2.3.jar这个包。

第二、自从struts2.1.6之后,<s:head theme="ajax" debug="true">就要用

<sd:head theme="xhtml" /><s:head parseContent="true" />两句代替,原因好像是因为struts2 的高版本吧ajax如何到dojo那个包里面去了,具体是啥样本人也不清楚,因为个人一直觉得达到自己要求就不用再去深究了,要用到的再深究。上面的<sd:......>的sd是<%@ taglib prefix="sd" uri="/struts-tags"%>标签

第三、在子节点要想达到点击跳到另一个页面的效果,需要在label标签中加上<a href="">显示的名称</a>

<s:tree>本来就用的很少。为了方便大家,我把自己页面的代码贴出来,供大家参考:

<%@ page language="java" contentType="text/html; charset=utf-8"
 pageEncoding="utf-8"%>
<%@ taglib prefix="sx" uri="/struts-tags"%>
<%@ taglib prefix="s" uri="/struts-dojo-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
 <head>
  <title>Struts 2 AJAX - Tree</title>
  <sx:head theme="xhtml" />
  <s:head parseContent="true" />
 </head>
 <body>
  <table width="100%" border="1">
   <tr>
    <td colspan="2" height="100px">
     <center>
      李仲声J2ee功能集
     </center>
    </td>
   </tr>
   <tr>
    <td height="500px" width="200px">
     <h2>
      Tree
     </h2>
     <div style="float: left; margin-right: 50px;">
      <s:tree label="parent" id="parentId"
       templateCssPath="/struts/tree.css" showRootGrid="true"
       showGrid="true">
       <s:treenode label="child1" id="child1Id">
        <s:treenode
         label="<a href='../lzs/mainwork/autoComplete/JQueryAutoComplete.html' target='show'>google搜索提示功能</a>"
         id="grandchild1Id" />
        <s:treenode label="grandchild2" id="grandchild2Id" />
        <s:treenode label="grandchild3" id="grandchild3Id" />
       </s:treenode>
       <s:treenode label="child2" id="child2Id" />
       <s:treenode label="child3" id="child3Id" />
       <s:treenode label="child4" id="child4Id" />
       <s:treenode label="child5" id="child5Id">
        <s:treenode label="gChild1" id="gChild1Id" />
        <s:treenode label="gChild2" id="gChild2Id" />
       </s:treenode>
      </s:tree>
     </div>
    </td>
    <td>
     <iframe src="../wellcome.jsp" scrolling="auto" frameborder="0"
      name="show" id="show"></iframe>
    </td>
   </tr>
  </table>
 </body>
</html>

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值