Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <body>
  2. <p>Hola bienvenido</p>
  3. <c:forEach items="${datos}" var="dato">
  4. <c:out value="${dato.ID}"/>
  5. </c:forEach>
  6. </body>
  7.  
  8. public DriverManagerDataSource conectar(){
  9. DriverManagerDataSource dm=new DriverManagerDataSource();
  10. dm.setDriverClassName("com.mysql.jdbc.Driver");
  11. dm.setUrl("jdbc:mysql://localhost/gameunity");
  12. dm.setUsername("root");
  13. dm.setPassword("");
  14. return dm;
  15. }
  16.  
  17. @Controller
  18. public class MainController {
  19. private JdbcTemplate template;
  20.  
  21. public MainController(){
  22. Conector con=new Conector();
  23. this.template=new JdbcTemplate(con.conectar());
  24. }
  25.  
  26. @RequestMapping("index.htm")
  27. public ModelAndView index(){
  28. ModelAndView res=new ModelAndView();
  29. String consulta="select * from cliente";
  30. List datos =this.template.queryForList(consulta);
  31. res.addObject("datos", datos);
  32. res.setViewName("index");
  33. return res;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement