Search code examples
javajspstruts2ognlvaluestack

How do I convert a JSP variable to a Struts2 variable?


How do I convert a JSP variable to a Struts2 variable?

I've tried the following:

<%=scoredDocument%>
<s:push value="scoredDocument"/>
<s:push value="#scoredDocument"/>
<s:push value="%{scoredDocument}"/>
<s:push value="${scoredDocument}"/>
<s:push value="#page.scoredDocument"/>
<s:push value="%{#page.scoredDocument}"/>

<display:column title="Study Code" sortable="true">
    <s:property value="id"/>

The most frequent error is

Caused by: tag 'push', field 'value': You must specify a value to push on the stack. Example: person - [unknown location]


Solution

  • <s:push> must enclose the <s:property> tag. Also

    <s:push value="#attr.scoredDocument">
        <display:column title="Study Code" sortable="true">
            <s:property value="id"/>
        </display:column>
    </s:push>
    

    #attr? WTF Struts? It's not even documented! https://struts.apache.org/release/2.0.x/docs/jsp.html