Spring(기초)-1주차(숙제)

Jonguk Kim·2021년 11월 15일
0

Spring

목록 보기
2/16

1. Person.java

package com.review.review01.models;

public class Person {
    private String name;
    private String address;
    private int age;
    private String job;

    // 기본 생성자
    public Person(){

    }

    // Getter
    public String getName(){
        return this.name;
    }

    public String getAddress(){
        return this.address;
    }

    public int getAge(){
        return this.age;
    }

    public String getJob(){
        return this.job;
    }

    // Setter
    public void setName(String name){
        this.name = name;
    }

    public void setAddress(String address){
        this.address = address;
    }

    public void setAge(int age){
        this.age = age;
    }

    public void setJob(String job){
        this.job = job;
    }

}

2. PersonController.java

package com.review.review01.controller;

import com.review.review01.models.Person;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PersonController {

    @GetMapping("/myinfo")
    public Person getPerson(){
        Person person = new Person();
        person.setName("손흥민");
        person.setAddress("런던");
        person.setAge(28);
        person.setJob("대한민국 축구선수");
        return person;
    }
}
profile
개발일지

0개의 댓글