Hi, I'm learning Struts2 , I'm doing a registration form but I have a question about how I can pull the records that are in a table to the s:select
tag (I practically want to make a > combobox pulling data from a field in a sql table).
This is my method of consulting the Database :
private String sql6= "select distinct RazonSocial from titular;";
public List<Propietario> consultarPr()throws SQLException{
List<Propietario> listadopr = new ArrayList<Propietario>();
Connection con=Coneccion.getConnection();
PreparedStatement ps=con.prepareStatement(sql6);
ResultSet res = ps.executeQuery();
while(res.next()){
Propietario p = new Propietario();
p.setNombres(res.getString("RazonSocial"));
listadopr.add(p);
}
ps.close();
res.close();
con.close();
return listadopr;
}
My action:
private List<Propietario> listadopr = new ArrayList<Propietario>();
public String consultarPr() throws SQLException{
ModelPropie ad = new ModelPropie();
listadopr = ad.consultarPr();
return SUCCESS;
}
My jsp:
<div class="form-group">
<label>Titular</label>
<s:iterator value="listadopr">
<s:select class="form-control select2" name="p.UEA" style="width: 100%;" list="value" listvalue="RazonSocial" headerKey="">
</s:select>
</s:iterator>
</div>
Where it says name p.UEA
is where the field is registered and I save it to the table of my Database .