我可以在 Struts 中将 <bean:write> 转换为 EL 吗?
Can I convert <bean:write> to EL in Struts?
如果我没记错的话,在Struts1.3中这三个表达式是等价的:
<bean:write name="form" property="foo" />
<c:out value="${form.foo}" />
${form.foo}
有什么不同吗?我发现的唯一一个是 <c:out>
escapes XML output, and ${}
doesn't. No idea about <bean:write>
, it says here 它在页面上下文中搜索 form
属性,然后在请求中搜索,然后在会话中搜索...但我猜 <c:out>
和 ${}
也这样做。
现在... 这个表达式会做什么?
<bean:write name="${form}" property"foo" />
我的猜测是 ${form}
部分首先被评估,然后它发现在 form
变量中命名的任何对象,并恢复它的 foo
属性。如果这确实是它的作用...我可以将它转换为 EL 吗?像这样,但实际上有效:
${${form}.foo}
自己回答最后一个问题:
根据this and this,我相信我可以这样使用<bean:define>
:
<bean:define id="blarg" name="${form}" property="foo" />
然后这将可用:
${blarg}
虽然我还没有测试过。
如果我没记错的话,在Struts1.3中这三个表达式是等价的:
<bean:write name="form" property="foo" />
<c:out value="${form.foo}" />
${form.foo}
有什么不同吗?我发现的唯一一个是 <c:out>
escapes XML output, and ${}
doesn't. No idea about <bean:write>
, it says here 它在页面上下文中搜索 form
属性,然后在请求中搜索,然后在会话中搜索...但我猜 <c:out>
和 ${}
也这样做。
现在... 这个表达式会做什么?
<bean:write name="${form}" property"foo" />
我的猜测是 ${form}
部分首先被评估,然后它发现在 form
变量中命名的任何对象,并恢复它的 foo
属性。如果这确实是它的作用...我可以将它转换为 EL 吗?像这样,但实际上有效:
${${form}.foo}
自己回答最后一个问题:
根据this and this,我相信我可以这样使用<bean:define>
:
<bean:define id="blarg" name="${form}" property="foo" />
然后这将可用:
${blarg}
虽然我还没有测试过。