`
xuke6677
  • 浏览: 12530 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类

这样嵌套循环,用什么标签<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>

相关推荐

Global site tag (gtag.js) - Google Analytics