@RestController 시작 전 준비과정이 궁금하다면?↓↓↓↓↓
https://maxtime1004.tistory.com/80
pom.xml에 해당 코드를추가합니다.
MemberVO
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
|
package com.myspring.pro29.ex01;
public class MemberVO {
private String id;
private String pwd;
private String name;
private String email;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
String info = id + ", " + pwd + ", " + name + ", " + email;
return info;
}
}
|
cs |
TestController
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
|
package com.myspring.pro29.ex01;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/test/*")
public class TestController {
@RequestMapping("/hello")
public String hello() {
return "Hello REST!!";
}
@RequestMapping("/member")
public MemberVO member() {
MemberVO vo = new MemberVO();
vo.setId("hong");
vo.setPwd("1234");
vo.setName("홍길동");
vo.setEmail("hong@test.com");
return vo;
}
}
|
cs |
실행결과
'코딩 기록 > JSP' 카테고리의 다른 글
[JSP] @PathVariable 사용하기 (0) | 2021.05.28 |
---|---|
[JSP] @RestController 이용해 컬렉션 객체 전달하기 (0) | 2021.05.28 |
[JSP] @RestController 문자열 전달하기 (0) | 2021.05.27 |
[JSP] REST 란? (0) | 2021.05.27 |
[JSP] MVC를 이용한 회원관리(수정/삭제) - 3 (0) | 2021.05.27 |