-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleController.java
More file actions
39 lines (33 loc) · 1.21 KB
/
SampleController.java
File metadata and controls
39 lines (33 loc) · 1.21 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
package org.zerock.springex.controller;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.time.LocalDate;
@Controller
@Log4j2
public class SampleController {
@GetMapping("/hello")
public void hello() {
log.info("hello....");
}
@GetMapping("/ex1")
public void ex1(String name, int age) { // query String의 Parameter들을 형변환해줌.
log.info("ex1.......");
log.info("name: {}",name);
log.info("age: {}",age);
}
@GetMapping("/ex2")
public void ex2(@RequestParam(name="name", defaultValue = "AAA") String name,
@RequestParam(name="age", defaultValue="20") int age) {
// RequestParam으로 query Parameter를 받고, 이름과 기본값을 정한 뒤 형변환
log.info("ex2.......");
log.info("name: {}",name);
log.info("age: {}",age);
}
@GetMapping("/ex3")
public void ex3(LocalDate dueDate) { // Date Parameter
log.info("ex3.......");
log.info("dueDate: {}", dueDate);
}
}