Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.hellospring4.controller; import java.sql.Date; import org.hellospring4.dao.GenericDao; import org.hellospring4.entities.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * * @author giovanni */ @Controller public class DemoController { GenericDao<User> dao; @Autowired public void setDao(GenericDao<User> dao) { this.dao = dao; dao.setClass(User.class); } @RequestMapping(value = "holamundo.php", method = RequestMethod.GET) public String holaMundo(Model model) { User user = new User(); user.setEmail("user@example.com"); user.setFname("Spring"); user.setLname("Tester"); user.setRegdate(new Date(2014, 07, 04)); dao.create(user); user = dao.find(1); System.out.println("\n\nUser name: " + user.getFname() + "\n" + user.getEmail()); return "paginaHolaMundo"; } @RequestMapping(value = "holarecs.php", method = RequestMethod.GET) public String testResources(Model model) { return "resources"; } }