I have this DAO Class,
public class CountriesDAO {
static final Logger logger = LogManager.getLogger(CountriesDAO.class.getName());
public List<SelectCountriesBean> getAllCountries() {
java.sql.Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
List<SelectCountriesBean> countries = new ArrayList<>();
try {
CreateConnection.loadProperties();
System.out.println("Beginning database connection to retrieve countries list");
conn = CreateConnection.getConnection();
pstmt = conn.prepareStatement("select * from KIRAN.TBHHCOUNTRY");
rs = pstmt.executeQuery();
while (rs.next()) {
SelectCountriesBean countrieslist = new SelectCountriesBean();
countrieslist.setCNCOUNTRYCODE(rs.getString("CNCOUNTRYCODE"));
countrieslist.setCNCOUNTRYNAME(rs.getString("CNCOUNTRYNAME"));
countries.add(countrieslist);
}
} catch (SQLException ex) {
logger.error("Countries retrival failed due to SQL Error", ex);
}
return countries;
}
}
This is my bean,
public class SelectCountriesBean {
private String CNCOUNTRYCODE;
private String CNCOUNTRYNAME;
/**
* @return the CNCOUNTRYCODE
*/
public String getCNCOUNTRYCODE() {
return CNCOUNTRYCODE;
}
/**
* @param CNCOUNTRYCODE the CNCOUNTRYCODE to set
*/
public void setCNCOUNTRYCODE(String CNCOUNTRYCODE) {
this.CNCOUNTRYCODE = CNCOUNTRYCODE;
}
/**
* @return the CNCOUNTRYNAME
*/
public String getCNCOUNTRYNAME() {
return CNCOUNTRYNAME;
}
/**
* @param CNCOUNTRYNAME the CNCOUNTRYNAME to set
*/
public void setCNCOUNTRYNAME(String CNCOUNTRYNAME) {
this.CNCOUNTRYNAME = CNCOUNTRYNAME;
}
}
This is my action
public class getAllCountries extends ActionSupport implements Preparable {
private List<SelectCountriesBean> countriesList;
CountriesDAO allCountriesDAO = new CountriesDAO();
public getAllCountries() {
}
@Override
public void prepare(){
}
@Override
public String execute() throws Exception {
countriesList = allCountriesDAO.getAllCountries();
return "success";
}
/**
* @return the countriesList
*/
public List getCountriesList() {
return countriesList;
}
/**
* @param countriesList the countriesList to set
*/
public void setCountriesList(List countriesList) {
this.countriesList = countriesList;
}
}
This is my JSP
<s:select name="COLCOUNTRY" list="countriesList" listKey="CNCOUNTRYCODE" listValue="CNCOUNTRYNAME" required="true"></s:select>
This is my struts.xml
<action name="getAllCountries" class="helpers.getAllCountries" method="execute" >
<result name="success">/WEB-INF/views/CreateAccountForm.jsp</result>
</action>
I get below message,
org.apache.jasper.JasperException: tag 'select', field 'list', name 'COLCOUNTRY': The requested list key 'countriesList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
I am out of thoughts now as why countriesList is not resolving as Collection.Can some one take a look and share some thoughts.