如何将 Struts <s:property /> 标签的值注入另一个标签

How to inject the value of a Struts <s:property /> tag into another tag

我想通过使用 Struts2 属性 标签 <s:property value="id"/> 来获取动作 class 中的一个属性的值,并将其赋予另一个标签,像这样(代码错误,仅供参考):

<t:tag id="<s:property value="id"/>"/>

我该怎么做?

注意:<t: 映射到自定义标签库。

你不能像那样嵌套(服务器端)标签;

如果您不清楚自己在做什么,我建议您坚持使用现有的标签库,standing on the shoulders of the giants;相反,如果您继承了它,并且不能删除它,请尝试使用 JSP EL 语法:

<t:tag id="${id}"/>

(值堆栈中的对象由 Struts2 请求包装器提供给 JSP EL)