Biblioteca Java - Blame information for rev 12
Subversion Repositories:
(root)/Spring/SpringWebMVC/webapp.form/src/main/java/hm/spring/web/controller/StudentController.java
Rev | Author | Line No. | Line |
---|---|---|---|
12 | mihai | 1 | package hm.spring.web.controller; |
2 | |||
3 | import org.springframework.stereotype.Controller; | ||
4 | import org.springframework.ui.ModelMap; | ||
5 | import org.springframework.web.bind.annotation.ModelAttribute; | ||
6 | import org.springframework.web.bind.annotation.RequestMapping; | ||
7 | import org.springframework.web.bind.annotation.RequestMethod; | ||
8 | import org.springframework.web.servlet.ModelAndView; | ||
9 | |||
10 | |||
11 | @Controller | ||
12 | public class StudentController { | ||
13 | |||
14 | @RequestMapping(value = "/student", method = RequestMethod.GET) | ||
15 | public ModelAndView student() { | ||
16 | return new ModelAndView("student", "command", new Student()); | ||
17 | } | ||
18 | |||
19 | @RequestMapping(value = "/addStudent", method = RequestMethod.POST) | ||
20 | public String addStudent(@ModelAttribute("SpringWeb")Student student, | ||
21 | ModelMap model) { | ||
22 | model.addAttribute("name", student.getName()); | ||
23 | model.addAttribute("age", student.getAge()); | ||
24 | model.addAttribute("id", student.getId()); | ||
25 | |||
26 | return "result"; | ||
27 | } | ||
28 | } |