Expresses an ognl expression to evaluate the result of an expression.

It will be a little difficult to explain. I am trying to write a tag for linking a bunch of address fields, but I am having trouble developing an ognl expression.

Expected Use:   

member.address matches the Address object (nothing is truncated).

my tag (simplest version):

<%@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>

I think the problem is that <s:push value="%{#attr.name}"/>it does not actually push the result of member.address on the stack, but simply push the String value of 'member.address'.

+3
source share
1 answer

A bit more research and looking at ognl documentation for a long time leads to the following:

<%@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>

This seems to be a trick.

+4
source

Source: https://habr.com/ru/post/1708199/


All Articles