Biblioteca Java - Blame information for rev 14

Subversion Repositories:
Rev:
Rev Author Line No. Line
14 mihai 1 package hm.spring.web.controller;
2  
3 import hm.spring.web.dao.StudentDAO;
4 import hm.spring.web.dao.StudentJDBCTemplate;
5 import hm.spring.web.domain.Student;
6  
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Controller;
9 import org.springframework.ui.ModelMap;
10 import org.springframework.web.bind.annotation.ModelAttribute;
11 import org.springframework.web.bind.annotation.RequestMapping;
12 import org.springframework.web.bind.annotation.RequestMethod;
13 import org.springframework.web.servlet.ModelAndView;
14  
15  
16 @Controller
17 public class StudentController {
18  
19  
20         @Autowired
21         StudentDAO studentJDBCTemplate;
22  
23            @RequestMapping(value = "/student", method = RequestMethod.GET)
24            public ModelAndView student() {
25               return new ModelAndView("student", "command", new Student());
26            }
27  
28            @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
29            public String addStudent(@ModelAttribute("SpringWeb")Student student,
30            ModelMap model) {
31               model.addAttribute("name", student.getName());
32               model.addAttribute("age", student.getAge());
33               model.addAttribute("id", student.getId());
34  
35               studentJDBCTemplate.create(student.getName(), student.getAge());
36  
37               return "result";
38            }
39         }