I know there are a buch of post related with this out there but none of them have worked for me.
I dont know if what I want to do is easy or no. I am very very new working with Spring.
The aplication is already working and I have to do some modifications, so I want to fill a dropdown box with data requested from a database.
This is my view:
<form:form action="${urlcallBankAddAction}" method="POST" onsubmit="return validar(this)" modelAttribute="banco">
<form:select path="descripcion" items="${resultList.descripcion}" />
</form:form>
This is my Controller:
@RequestMapping(value = {"/details", "/details?status={status}"}, method = RequestMethod.GET)
public String verBancos(WebRequest request,
ModelMap model,
HttpSession session){
try{
String valorSesion = (String) session.getAttribute("acceso");//Se valida el inicio de sesion
if(valorSesion.equals("1")){//Se valida el inicio de sesion
List<Banco> result = new ArrayList<Banco>();
List<String> banksResults = new ArrayList<String>();
result = bancoService.obtenerTodosLosBancos();
model.addAttribute("currentComponent", "banks.title");
model.addAttribute("status", request.getParameter("status"));
model.addAttribute("resultList", result);
model.addAttribute("banco", new Banco());
model.addAttribute("cantidadRegistros", result.size());
return "details";
} else{
//MANDAR A PAGINA DE ERROR
return "redirect:/unauthorized";
}
} catch(NullPointerException n){//Se valida el inicio de sesion
//MANDAR A PAGINA DE ERROR
return "redirect:/unauthorized";
}
}
And this is the Model, the sets and gets are there but I Omitted in here:
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "cod_visa")
private int codigoVisa;
@Column(name = "CodSud")
private String codigoSudeban;
@Column(name = "descripcion"
Something curious about all this is that I already have the data as you can see in the image below, but I only Want to display in my box the description of those clients, the arrow denotes where I want to put my description.
With the current view I got this exception:
Caused by: java.lang.NumberFormatException: For input string: "descripcion"
And I also tried filling the box with a c:forEach items="${resultList.description} with no result and I used only the "resultList" and then I got the whole object obtained from DB.
Please help me out with this, I dont know what I am missing or what I am doing wrong. I have faced so many problems with this.
