"getMapping sayHello Method run" 이란 문자열을 Get방식을 통해 브라우저에 바로 출력하고자 한다
그냥 @Controller는 객체 정보를 바로 출력해 주는 것이 아니라 view(html이나 thymeleaf)를 반환하기 때문에 객체 정보가 나오지 않았다
이를 해결하기 위해서는 해당 컨트롤러 클래스의 어노테이션을 @RestController로 변경
@RestController = @Controller + @ResponseBody
@ResponseBody는 객체 정보를 출력해줄 수 있는 어노테이션(view가 아니라 data)
✏️String 리턴
✏️instance 리턴
728x90
반응형
'🔻Back-End > Spring' 카테고리의 다른 글
[Spring error] Column 'content' cannot be null (0) | 2022.10.29 |
---|---|
[Spring] 스프링 프로젝트를 DB와 연결하기 (0) | 2022.10.29 |
[Spring] REST, RESTAPI (0) | 2022.10.27 |
[Spring error] localhost:8080에 로그인화면 보일 때 (0) | 2022.10.23 |
[Spring] Spring boot란 (0) | 2022.10.23 |