【问题标题】:how to display dynamic string value in struts treenode tag using java如何使用java在struts treenode标签中显示动态字符串值
【发布时间】:2013-07-10 12:24:17
【问题描述】:

下面是我的sample.jsp 我的要求是显示树结构格式。

<%@ taglib prefix="s" uri="/struts-tags" %>
<%
  String s="ROOT";
  %>
  <s:tree theme="ajax" id="root" label="%{s}"> 
  <s:treenode theme="ajax" id="child1" label="<b>Child 1</b>" />
  <s:treenode theme="ajax" id="subchild1" label="SubChild 1">
  <s:treenode theme="ajax" id="subchild2" label="SubChild 2" />
  <s:treenode theme="ajax" id="subchild3" label="SubChild 3" />
  </s:treenode>
  <s:treenode theme="ajax" id="child2" label="<b>child 2</b>" />
 </s:tree>

但它没有在

中显示 s 值
<s:tree theme="ajax" id="root" label="%{s}"> 

请建议我如何做到这一点? 谢谢

【问题讨论】:

    标签: java jsp struts2 treenode


    【解决方案1】:

    第一件事:使用 scriptlet 是一种非常糟糕的做法,请改用 taglibs。

    但是如果你真的需要这个然后使用&lt;s:set&gt;标签来分配变量。

    <%
     String s="ROOT";
    %>
    <s:set var="sVar">
      <%=s %>
    </s:set>
    <sj:tree theme="ajax" id="root" label="%{#sVar}">
    

    顺便说一句,/struts-tags 中没有 tree 这样的东西你可能是指/struts-jquery-tags

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      相关资源
      最近更新 更多