【问题标题】:Are there any tags In Struts2 that emulate the 'nested' tag of Struts 1?Struts2 中是否有任何标签可以模拟 Struts 1 的“嵌套”标签?
【发布时间】:2013-06-27 10:04:29
【问题描述】:

基本上我想在 Struts 2 中模拟 Struts 1 中的这个标签(和行为): 示例...

<nested:write property="myNestedLevel.propertyOne" />
<nested:write property="myNestedLevel.propertyTwo" />
<nested:write property="myNestedLevel.propertyThree" />

可以改为...

<nested:nest property="myNestedLevel" >
  <nested:write property="propertyOne" />
  <nested:write property="propertyTwo" />
  <nested:write property="propertyThree" />
</nested:nest >

我为我的每个视图创建视图模型对象。由于其中一些视图可能在其他 View JSP 文件中重用,嵌套在 View 中的 View JSP 将具有嵌套在另一个 ViewModelObject 中的等效 ViewModel 对象,该对象表示具有嵌套(重用)视图组件的整个视图。

任何人都可以想到一种方法吗?

【问题讨论】:

    标签: struts2 struts struts-1


    【解决方案1】:

    最简单、最明显的方法是使用&lt;s:push&gt;

    <s:push value="myNestedLevel">
      ${propertyOne}
      ${propertyTwo}
      ${propertyThree}
    </s:push>
    

    【讨论】:

    • 太棒了!这正是我想要的。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2011-04-19
    • 1970-01-01
    • 2014-05-16
    • 2012-12-23
    • 2011-10-07
    • 2013-03-30
    相关资源
    最近更新 更多