Use the
IterateBean.java:
Package beantest;
Import org.apache.struts.Action.actionform;
public class IterateBean extends ActionForm {private String [] name_coll = null; public void setName_coll (String [] name_coll) {this.name_coll = name_coll;} public String [] getName_coll () {return this.name_coll;} private String [] name_new = null; public void setName_new (String [] name_new) {System.out.println ( "IterateBean: setName_new (String [])"); this.name_new = name_new;} public String [] getName_new () {return this.name_new }}
IteeAction.java
Package beantest;
Import javax.servlet.http.httpservletRequest; import javax.servlet.http.httpservletResponse;
Import org.Apache.struts.Action.Act; import org.apache.struts.action.actionform; import org.apache.struts.action.actionforward; import org.apache.struts.Action.Apache.APPING;
public class IterateAction extends Action {public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {IterateBean ibean = (IterateBean) form; String [] temp = { "bitan", "helen"}; ibean. SetName_coll (Temp); Temp = new string [] {"aaaaa", "bbbb"}; ibean.setname_new (temp); return maping.findforward ("Iterate-View");}}
Iterate-view.jsp:
<% @ Page ContentType = "text / html; charset = GB2312"%>
<% @ Taglib Uri = "/ Web-inf / struts-logic.tld" prefix = "logic"%> <% @ Taglib URI = "/ Web-inf / struts-bean.tld" prefix = "bean"%>
logic: Iterate>
★ 〓〓〓〓〓〓〓 ★
logic: iperate>
Lower.jsp:
Hello, Iterate! font>
Struts-config.xml:
XML Version = "1.0" Encoding = "ISO-8859-1">
XML Version = "1.0"?>
web-app>
Output effect:
Name: Bitan; Code: Aaaaaname: Bitan; Code: bbbbb ★ 〓〓〓〓〓〓〓 ★ Hello, Ite: Aaaaaname: Helen; Code: bbbbb ★ 〓〓〓〓〓〓〓 ★ ★ 〓〓;; Hello, Iteerate!
As shown above, multiple variables cannot be simultaneously output directly in a cycle; but nesting cycles in the loop can achieve a complex effect.
To achieve multiple variables simultaneously in a loop, you can reference