【问题标题】:How to inject the value of a Struts <s:property /> tag into another tag如何将 Struts <s:property /> 标签的值注入另一个标签
【发布时间】:2015-06-22 14:06:26
【问题描述】:

我想通过使用 Struts2 属性标签 &lt;s:property value="id"/&gt; 来获取动作类中属性的值并将其提供给另一个标签,类似这样(错误代码,只是为了给出想法):

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

我该怎么做?

注意:&lt;t: 映射到自定义标签库。

【问题讨论】:

  • &lt;t: 是什么?另一个标签库?或者这是一个错误,你的意思是&lt;s:
  • 它可以读到什么? JSP EL ?
  • 只是一个数字,我还是个新人
  • 你是新手,你写了蹩脚的标签库?坚持现有的,站在巨人的肩膀上!相反,如果您正在继承它,并且不能放弃它...请尝试像我将很快发布的答案中一样

标签: jsp struts2 el taglib struts-tags


【解决方案1】:

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

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

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

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

【讨论】:

    猜你喜欢
    • 2014-10-04
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多