WebWork Label iterator use case

Source: Internet
Author: User
Javebean
Package ch9;

public class Testbean ... {
private String name;
Private String age;
Public String getage () ... {
return age;
}
public void Setage (String age) ... {
This.age = age;
}
Public String getName () ... {
return name;
}
public void SetName (String name) ... {
THIS.name = name;
}
}


Action:

Separately constructs List,set,map three most commonly used collection, needs to note is the WebWork Traversal map label is according to the key from the small to the large sort output, therefore, the suggestion key as the ordinal saves, uses the shaping, if is the string line, the sort is indeterminate, I did not find the string Key's Sort setting method

The code is simple, the effect can refer directly to JSP package CH9;

Import java.util.ArrayList;
Import Java.util.HashMap;
Import Java.util.HashSet;
Import java.util.List;
Import Java.util.Map;
Import Java.util.Set;

Import Javax.servlet.http.HttpServletRequest;

Import Com.opensymphony.webwork.interceptor.ServletRequestAware;
Import com.opensymphony.xwork.Action;
Import Com.opensymphony.xwork.ActionSupport;

/** */ /**
* @author $author
*/
public class Testiteratoraction extends Actionsupport implements Servletrequestaware ... {

HttpServletRequest Request=null;
Testbean testbean1=new Testbean ();
Testbean testbean2=new Testbean ();
List a=new ArrayList ();
Map b=new HashMap ();
Set c=new HashSet ();
Public List Geta () ... {
return A;
}
public void SetA (List a) ... {
THIS.A = A;
}
Public Map Getb () ... {
return b;
}
public void Setb (Map b) ... {
this.b = b;
}
public void Setservletrequest (HttpServletRequest request) ... {
This.request=request;

}
Public String Execute () throws Exception
... {
Testbean1.setage ("11");
Testbean1.setname ("Gaoxiang");
Testbean2.setage ("22");
Testbean2.setname ("Yulihua");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.