Ver Mensaje Individual
  #4 (permalink)  
Antiguo 11/05/2013, 19:22
darkChild
 
Fecha de Ingreso: marzo-2012
Ubicación: Argentina
Mensajes: 111
Antigüedad: 12 años, 1 mes
Puntos: 12
Respuesta: SPRING MVC - Como obtener la variable para iterar en la vista JSP

No se como lo muestres es problema tuyo pero la clave esta en el controller

voy a tratar de ser mas claro

Este es mi controller bien basico
Código C++:
Ver original
  1. @Controller
  2. @RequestMapping("/welcome")
  3. public class HelloWorldController {
  4.  
  5.     @RequestMapping(method = RequestMethod.GET)
  6.     public ModelAndView helloWorld() {
  7.  
  8.  
  9.         List<String> list = new ArrayList<String>();
  10.         ModelAndView model = new ModelAndView("HelloWorldPage");
  11.         list.add("uno");
  12.         list.add("dos");
  13.         list.add("tres");
  14.         model.addObject("lista", list);
  15.  
  16.  
  17.         return model;
  18.     }
  19. }

y el jsp el siguiente

Código HTML:
Ver original
  1. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  2.     <h1>Spring MVC Hello World Annotation Example</h1>
  3.  
  4.     <h2>${lista}</h2>
  5.  
  6. </body>
  7. </html>

y la salida en la web

Código HTML:
Ver original
  1.     <h1>Spring MVC Hello World Annotation Example</h1>
  2.  
  3.     <h2>[uno, dos, tres]</h2>
  4.  
  5.  
  6. </body></html>