Replies: 1 comment 3 replies
-
| 정리는 굳굳 | 
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
글을 시작하기 전에
웹을 개발한다는 것은 크게 3가지로 나눌 수 있다.
정적 컨텐츠
https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/html/spring-boot-features.html#boot-features-spring-mvc-static-content
resources/static/hello-static.html실행화면

페이지 소스 보기 클릭 시
localhost:8080/hello-static.html를 치면 내장 톰켓 서버가 요청을 받아 스프링에게 넘긴다.즉, 컨트롤러가 먼저 우선순위를 가진다.
resources/static/hello-static.html을 찾는다.정적컨텐츠 정리 !
MVC와 템플릿 엔진
Controller
View
resources/templates/hello-template.htmltemplates/hello-template.html여기서 리턴과 같은 이름을 찾아 thymeleaf 템플릿 엔진에게 넘겨준다.API
Controller
@ResponseBody어노테이션을 사용 할 경우 ViewResolver를 사용하지 않는다.localhost:8090/hello-string?name=spingResponseBody 객체 반환
@ResponseBody를 사용하고, 객체를 반환하면 객체가 JSON으로 변환된다.localhost:8090/hello-api?name=spring@ResponseBody라는 어노테이션이 붙어있으면 응답에 그대로 데이터를 넘긴다.@ResponseBody를 사용 할 경우viewResolver대신HttpMessageConverter가 동작한다.HTTPMessageConverter가 객체 라면 JsonConverter , 문자열이면 StringConverter 를 거쳐 웹 브라우저에게 전달한다.Beta Was this translation helpful? Give feedback.
All reactions