-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeptController.java
More file actions
48 lines (34 loc) · 1.15 KB
/
DeptController.java
File metadata and controls
48 lines (34 loc) · 1.15 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
package com.spring.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import com.spring.dto.Dept;
import com.spring.service.DeptService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@Controller
public class DeptController {
@Autowired
DeptService dservice;
@GetMapping("/deptAll")
public String deptAll(Model m) {
List<Dept> dlist = dservice.deptAll();
m.addAttribute("deptAll",dlist);
return "dept/deptAll";
}
@GetMapping("/dept/form") // 부서 번호 자동완성
public String form(Model m) {
m.addAttribute("deptno",dservice.newNo());
return "dept/form";
}
@PostMapping("/dept/insert")
public String insert(Model m, Dept d) {
dservice.insertDept(d);
List<Dept> dlist = dservice.deptAll();
m.addAttribute("deptAll",dlist);
return "dept/result";
}
}