struts中iterate标签的一个例子(一层嵌套)

类别:Java 点击:0 评论:0 推荐:
在action里servletRequest.setAttribute(“survey“,survey);
jsp文件片断(注意:不需usebean,标签会自动找):

<nested:write name="survey" property="title"/><br>
 <nested:write name="survey" property="poster"/><br>
 <nested:write name="survey" property="postDate"/><br>
 <nested:iterate id="item" name="survey" property="items" type="survey.SurveyItem">
  <nested:equal name="item" property="type" value="select_single">
        <nested:write  property="title"/><br>
        options:<br>
    <nested:iterate id="option" name="item" property="options" type="survey.SurveyItemOption">
                <nested:write property="index"/>
                <nested:write property="text"/><br>
    </nested:iterate>
  </nested:equal>
  <nested:equal name="item" property="type" value="select_multi">
        <nested:write  property="title"/><br>
   options:<br>
    <nested:iterate id="option" name="item" property="options" type="survey.SurveyItemOption">
                <nested:write property="index"/>
                <nested:write property="text"/><br>
    </nested:iterate>
  </nested:equal>
        <nested:equal name="item" property="type" value="text">
        <nested:write  property="title"/><br>
  </nested:equal>
   </nested:iterate>

本文地址:http://com.8s8s.com/it/it11521.htm