在 Struts 2.5 中使用顶部对象

Using top object in Struts 2.5

根据s2-026

Support for expression using top will be dropped in upcoming Struts version 2.5!

我们在很多 JSP 页面中使用了 top 对象,如下所示(其中显示了 currencyTypes 的列表并查找来自 Struts 封邮件的姓名):

<s:select name = "selectedCurrencyType" 
          list = "currencyTypes"
       listKey = "top" 
     listValue = "%{getText('acc.currencyType.'+top)}" />

它目前适用于 struts 2.3.24.1 但根据上面的评论,上面的 select 框是否适用于 2.5,否则我们将没有任何顶部参考更多?!

如果这是真的,请告诉我我们应该如何解决上面的问题 s:select?!

我在本文档中找到的内容以及我在示例 Passing parameters to action through ModelDriven in Struts 2 the top object is a element of the CompaundRoot. And this class has a cutStack() 中使用的方法

With expression like [0] ... [3] etc. Struts 2 will cut the stack and still return back a CompoundRoot object. To get the top of that particular stack cut, use 0.top.

最后一个表达式是 [xxx].top 的拼写错误,其中 xxxCompoundRoot 对象的索引。这个对象可以被引用为 [xxx]。它是一个 top 对象切割到 xxx 索引。

添加了对 top 对象的支持以支持内部操作,用户不应使用它(是的,在文档中表达它是个坏主意 :( )

无论如何,看来我们必须准备一个迁移路径或保持对 top 对象的支持。