题
这将是有点棘手解释。我试图写一个标签componentise一串地址字段,但我无法工作了OGNL表达式。
预期用法:
member.address映射到Address对象(没有太切割)。
我的标签(最简单的版本):
<%@taglib prefix="s" uri="/struts-tags" %>
<%@attribute name="name" required="true" rtexprvalue="true" type="java.lang.String" %>
<s:push value="%{#attr.name}">
Address line 1:
<s:property value="line1"/>
</s:push>
我认为这个问题是<s:push value="%{#attr.name}"/>
实际上没有推member.address结果到堆栈它只是推,而不是价值“member.address”的字符串。
解决方案
一个小更多的研究和很长的时间在 OGNL文档凝视一>结果如下:
<%@taglib prefix="s" uri="/struts-tags" %>
<%@attribute name="name" required="true" rtexprvalue="true" type="java.lang.String" %>
<s:push value="%{(#attr.name)(#attr)}">
Address line 1:
<s:property value="line1"/>
</s:push>
似乎待办事项特技。
不隶属于 StackOverflow