当前位置: 代码迷 >> Web前端 >> 这样嵌套循环,用什么标签<c:foreach>还是<logic>第二个循环是根据第一个循环条件获得的
  详细解决方案

这样嵌套循环,用什么标签<c:foreach>还是<logic>第二个循环是根据第一个循环条件获得的

热度:781   发布时间:2012-09-18 16:21:42.0
这样嵌套循环,用什么标签<c:foreach>还是<logic>?第二个循环是根据第一个循环条件获得的
package com.svse.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.svse.struts.entity.TBoard;
import com.svse.struts.entity.TType;
import com.svse.struts.form.BoardForm;
import com.svse.struts.impl.BoardImpl;
import com.svse.struts.impl.TypeImpl;
import com.svse.struts.service.BoardService;
import com.svse.struts.service.TypeService;

public class BoardAction extends DispatchAction
{

	private BoardService boardService = new BoardImpl();
	private TypeService typeService = new TypeImpl();

	/***
	 * 
	 */
	public ActionForward all(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	{
		BoardForm boardForm = (BoardForm) form;

//怎么在demo.jsp页面中显示所查询的type.getTName()和board.getBName()的值,向这样嵌套循环,用什么标签<c:foreach>还是<logic>?第二个循环是根据第一个循环条件获得的
		List<TType> typeList = typeService.getAllType();
		for (TType type : typeList) {
			System.out.println(type.getTName());
			List<TBoard> title = boardService.getAllTitle(type.getTId());//根据ID查询所有版面信息

			request.setAttribute("title", title);
			for (TBoard board : title) {
				System.out.println("________________"+board.getBName());
			}
		}
		
		return new ActionForward("/user/demo.jsp",false);//请求转发
	}
}

1 楼 夜里几度惆怅 2012-01-10  
后台:request.setAttribute("typeList", typeList );
request.setAttribute("title ", title );
demo.jsp用<c:forEach items="${typeList}" var="TType"></c:forEach>
  相关解决方案