Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- replace()
- 아스키코드
- 백엔드
- StringBuilder
- 이행시
- Controller
- upc
- 문자열
- 스프링
- CS
- 어노테이션
- bit
- string
- Spring
- yeouido
- 개발
- repository
- 삼행시
- 자바
- 윤동주
- StringBuffer
- lombok
- Annotation
- java
- Service
- 항해
Archives
- Today
- Total
Dev.끄적끈적
Spring 입문 week1 본문
Person.java 에서 set과 get을 만들어줌.
package com.sparta.week01.prac;
public class Person {
private String name;
private int age;
private String address;
private String job;
public Person(){
}
public Person(String names, int ages, String addresses, String jobs){
this.name = names;
this.age = ages;
this.address = addresses;
this.job = jobs;
}
public void setName(String names){
this.name = names;
}
public void setAge(int ages){
this.age = ages;
}
public void setAddress(String addresses){
this.address = addresses;
}
public void setJob(String jobs){
this.job = jobs;
}
public String getName(){
return this.name;
}
public int getAge(){
return this.age;
}
public String getAddress(){
return this.address;
}
public String getJob(){
return this.job;
}
}
PersonController.java : allow the server to get /person data
package com.sparta.week01.controller;
import com.sparta.week01.prac.Course;
import com.sparta.week01.prac.Person;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PersonController {
@GetMapping("/person")
public Person getPerson() {
Person p = new Person();
p.setName("이 건 도");
p.setAge(30);
p.setAddress("여의도");
p.setJob("재벌");
return p;
}
}
'Spring' 카테고리의 다른 글
Controller, Service, Repository 역할, 분리 (0) | 2022.03.27 |
---|---|
리팩토링이란? (0) | 2022.03.27 |
HTTP 메시지 이해하기 (0) | 2022.03.26 |
IntelliJ Annotation processing 설정 (0) | 2022.03.24 |
Spring 입문 강의 Notion 링크 (0) | 2022.03.23 |