【问题标题】:Can I convert <bean:write> to EL in Struts?我可以在 Struts 中将 <bean:write> 转换为 EL 吗?
【发布时间】:2018-04-30 12:01:23
【问题描述】:

如果我没记错的话,在 Struts 1.3 中这三个表达式是等价的:

<bean:write name="form" property="foo" />

<c:out value="${form.foo}" />

${form.foo}

有什么不同?我发现的唯一一个是&lt;c:out&gt; escapes XML output, and ${} doesn't。不知道&lt;bean:write&gt;,它说here 在页面上下文中搜索form 属性,然后在请求中,然后在会话中......但我猜&lt;c:out&gt;${} 这样做,也是。

现在... 这个表达式会做什么?

<bean:write name="${form}" property"foo" />

我的猜测是${form} 部分首先被评估,然后它发现在form 变量中命名的任何对象,并恢复其foo 属性。如果这实际上是它的作用... 我可以将它转换为 EL 吗?像这样的东西,但实际上有效:

${${form}.foo}

【问题讨论】:

    标签: jsp struts el


    【解决方案1】:

    自答最后一个问题:

    根据thisthis,我相信我可以这样使用&lt;bean:define&gt;

    <bean:define id="blarg" name="${form}" property="foo" />
    

    然后这将变得可用:

    ${blarg}
    

    不过我还没有测试过。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-22
      • 2011-12-30
      • 1970-01-01
      • 2020-06-30
      • 2010-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多