logic:iterate和bean:write 的使用

<a href="http://localhost:8088/mylogin/forward.do?key=value">forward</a>


public class SchemeAction extends LookupDispatchAction{

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		String str=request.getParameter("key");
		System.out.println("--------"+str);
		
		this.see(request,response);
		return mapping.findForward("welcome");
	}
	
	
	public static void see(HttpServletRequest request, HttpServletResponse response){
		
		List list=new ArrayList();
		for(int i=0;i<5;i++){
			FormBean formbean=new FormBean();
			[color=blue]formbean.setName("ghr"+i);
			formbean.setSex("sex"+i);
			formbean.setAge("age"+i);[/color]
			list.add(formbean);
		}
		request.setAttribute("[color=darkred]list[/color]", list);
	} 
	
	@Override
	protected Map getKeyMethodMap() {
		// TODO Auto-generated method stub
		return null;
	}
	
}


<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>




<table border=1>
  <tr><td width=40>姓名</td>
  <td width=40>性别</td>
  <td width=40>年龄</td></tr>
    <logic:iterate id="su" name=" list">
    <tr><td><bean:write name="su" property=" name"/></td>
    <td><bean:write name="su" property=" sex"/></td>
    <td><bean:write name="su" property=" age"/></td></tr>
    </logic:iterate>
    </table>

你可能感兴趣的:(java,bean,Web,struts)