Action Class Code
public class DropDown extends ActionSupport{ private List arrUserDetails = new ArrayList<Users>(); public DropDown() { Users objUsers = new Users(); objUsers.setUserId("101"); objUsers.setUserName("User1"); arrUserDetails.add(objUsers); objUsers.setUserId("102"); objUsers.setUserName("User2"); arrUserDetails.add(objUsers); objUsers.setUserId("103"); objUsers.setUserName("User3"); arrUserDetails.add(objUsers); } public String execute(){ return SUCCESS; } public List getArrUserDetails() { return arrUserDetails; } public void setArrUserDetails(List arrUserDetails) { this.arrUserDetails = arrUserDetails; } }
Users Bean Class
public class Users { private String userId; private String userName; public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } }
JSP Page Struts2 Tag
<s:select label="Departments" list="departmentList" listKey="deptId" listValue="deptName" name="department"/>