poring91
poring91

Reputation: 523

How to get xml result param value for jsp

I want to put a result param named contents from action XML to <s:include> tag value attribute to add other JSP file dynamically. This is what inside the JSP page :

<s:include value="%{#parameters['contents']}"/>

And this is the action result inside xml

<action name="list" class="control.action.hrp.AllowanceList">
    <result name="success" type="dispatcher">
        <param name="location">/WEB-INF/main/template/body.jsp</param>
        <param name="contents">/WEB-INF/main/content/Content.jsp</param>
    </result>
    <result name="error">/index.jsp</result>
</action>

The body.jsp doesn't load "Content.jsp"
Is there any way to put the value of contents param to JSP ?

Thanks for any help that you suggest.

Upvotes: 2

Views: 730

Answers (1)

Aleksandr M
Aleksandr M

Reputation: 24396

First of all, you need to create a contents variable in your control.action.hrp.AllowanceList action with getter/setter.

The param tag in struts.xml should be directly inside action tag not a result tag.

<action name="list" class="control.action.hrp.AllowanceList">
    <param name="contents">/WEB-INF/main/content/Content.jsp</param>

    <result name="success" type="dispatcher">/WEB-INF/main/template/body.jsp</result>
    <result name="error">/index.jsp</result>
</action>

And in JSP just use contents variable:

<s:include value="%{contents}"/>

Upvotes: 1

Related Questions