Wednesday, August 09, 2006

Iterate problem in Strtuts

When I transfer a variable of action class to jsp, I find some thing interesting:
If the variable is an Array, then in jsp, I need to write both first two line(1 and 2):

1: <logic:iterate id="dish" name="dishes" type="myPack.Dish">
2: <logic:present name="dish">
3: <bean:write name="dish" property="dishName">
4: </bean:write>
5: </logic:present>
6: </logic:iterate>

then no problem. If I kill the no.2 line then jsp can't find the bean "dish". However, If the value is an ArrayList, no need to write no.2 line, it can work well without no.2 line.
Note: dishes is the variable, it can be transferred from action class in the following way: request.setAttribute("dishes",dishes1);

No comments: