-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegController.java
More file actions
68 lines (57 loc) · 1.91 KB
/
RegController.java
File metadata and controls
68 lines (57 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.dao.RegDao;
import com.vo.RegVo;
@Controller
public class RegController
{
@Autowired
RegDao regdao;
@RequestMapping(value="load",method=RequestMethod.GET)
public ModelAndView loadInsert()
{
return new ModelAndView("insert","x",new RegVo());
}
@RequestMapping(value="/insert",method=RequestMethod.POST)
public ModelAndView dataInsert(@ModelAttribute RegVo r)
{
this.regdao.insert(r);
return new ModelAndView("redirect:load.htm");
}
@RequestMapping(value="/display",method=RequestMethod.GET)
public ModelAndView displaytable(RegVo r)
{
List ls = regdao.search(r);
return new ModelAndView("table","List",ls);
}
@RequestMapping(value="/delete")
public ModelAndView delete(RegVo r, @RequestParam("id")int i)
{
r.setId(i);
this.regdao.delete(r);
return new ModelAndView("redirect:load.htm");
}
@RequestMapping(value="/edit")
public ModelAndView update(RegVo r, @RequestParam("id")int i, HttpServletRequest request)
{
r.setId(i);
List ls = regdao.search1(r);
return new ModelAndView("edit", "data", (RegVo)ls.get(0));
}
@RequestMapping(value="/update",method=RequestMethod.POST)
public ModelAndView edit(@ModelAttribute RegVo r,@RequestParam("id")int i ,HttpServletRequest request)
{
r.setId(i);
this.regdao.edit(r);
return new ModelAndView("redirect:load.htm");
}
}