list集合存list 以及s標籤在foreach迴圈遍歷中用EL表示式取值
阿新 • • 發佈:2019-01-29
特點總結: 在一個iterator集合容器中遍歷另外一個list中的list的,通過iterator中的 status="status"狀態為,同時 <a href="<s:url action="fileformAction_download"/>?fileid=${bean.fileid}">${bean.filename}</a> 解決了s標籤中無法用EL表示式取值的難題。 controller中的程式碼: List<List<Fileform>> fileformlilist=new ArrayList<List<Fileform>>(); for(int i=0;i<projectlist.size();i++){ List<Fileform> filelist=fileformService.ByOtherId(projectlist.get(i).getProjectid()); fileformlilist.add(i, filelist); } ActionContext.getContext().put("fileformlilist", fileformlilist); jsp中的程式碼: <tbody id="TableData" class="dataContainer" datakey="projectList"> <s:iterator value="#getProjectpage" status="status"> <tr class="TableDetail1 template"> <td align="center">${status.index + 1} </td> <td align="center">${projectname} </td> <td align="center">${employeename} </td> <td align="center"> <c:forEach items="${fileformlilist.get(status.index)}" var="bean"> <a href="<s:url action="fileformAction_download"/>?fileid=${bean.fileid}">${bean.filename}</a> </c:forEach></td> <td align="center"> <s:a action="projectAction_infoUI?projectid=%{projectid}">檢視</s:a> <s:a action="projectAction_editUI?projectid=%{projectid}">修改</s:a> <s:a action="projectAction_delete?projectid=%{projectid}" onclick="return window.confirm('這將刪除本條宿舍資訊,你確定要刪除嗎?')">刪除</s:a> </td> </tr> </s:iterator> </tbody></span>