You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by albert kao <al...@gmail.com> on 2019/02/16 13:03:35 UTC

How to use s:iterator s:include s:param

This display properly:
<s:if test="#session.response.items.itemList">
  <s:iterator value="#session.response.items.itemList">
    <s:property value="description"/>
  </s:iterator>
</s:if>

I refactor to the following two files, which display nothing.
I have other codes in items.jsp which confirms that items.jsp is being used
in showitems.jsp.
Please help.
Thanks.

items.jsp:
<s:set var="itemList" value="%{parameters.itemList}"/>

<s:if test="%{itemList}">
  <s:iterator value="%{parameters.itemList}">
    <s:property value="description"/>
  </s:iterator>
</s:if>



showitems.jsp:
<s:include value="items.jsp">
  <s:param name="itemList" value="#session.response.items.itemList"/>
</s:include>

Re: How to use s:iterator s:include s:param

Posted by Yasser Zamani <ya...@apache.org>.
Hi Albert,

I found following at [1].

"Note: Any additional params supplied to the included page are not
accessible within the rendered page through the <s:property…> tag since
no valuestack will be created. You can, however, access them in a
servlet via the HttpServletRequest object or from a JSP page via a
scriptlet.

How To access parameters

Parameters are passed as request parameters, so use the
${param.ParamName} notation to access them. Do not use the property tag
to access parameters in included files."

So it seems you can use ${param.itemList}.

Thanks for using Struts!

Regards.

[1] https://struts.apache.org/tag-developers/include-tag.html

On 2/16/2019 4:33 PM, albert kao wrote:
> This display properly:
> <s:if test="#session.response.items.itemList">
>   <s:iterator value="#session.response.items.itemList">
>     <s:property value="description"/>
>   </s:iterator>
> </s:if>
> 
> I refactor to the following two files, which display nothing.
> I have other codes in items.jsp which confirms that items.jsp is being used
> in showitems.jsp.
> Please help.
> Thanks.
> 
> items.jsp:
> <s:set var="itemList" value="%{parameters.itemList}"/>
> 
> <s:if test="%{itemList}">
>   <s:iterator value="%{parameters.itemList}">
>     <s:property value="description"/>
>   </s:iterator>
> </s:if>
> 
> 
> 
> showitems.jsp:
> <s:include value="items.jsp">
>   <s:param name="itemList" value="#session.response.items.itemList"/>
> </s:include>
>