@GetMapping("hello-string")
@ResponseBody
public String helloString(@RequestParam("name")String name){
return "hello " + name;
}
static class Hello{ // 예시를 위해 정적 클래스 선언
private String name;
public getName(){
return this.name;
}
public setName(String name){
this.name = name;
}
}
@GetMapping("hello-api")
@ResponseBody
public helloApi(@RequestParam("name") String name){
Hello hello = new Hello();
hello.setName("leejaebeen");
return hello;
}
json형식으로 객체 hello( “name”:”leejaebeen”
)가 리턴됨을 확인할 수 있다.
domain