스프링 웹 개발 기초

ttaho·2023년 1월 17일

Spring

목록 보기
1/13

정적 컨텐츠

파일을 그대로 웹 브라우저에 내려준다.
main/resorces/static/hello-static.html

실행

http://localhost:8080/hello-static.html

MVC 방식과 템플릿 엔진

MVC: Model, View, Controller


localhost:8080/hello-mvc?name=ttaho를 보내면 파라미터로 넘어온 name을
hello-template.html의 name값에 ttaho를 넣어서 보낸 후 hello-template.html를 보여준다

API

@ResponseBody를 사용

  • HTTP의 BODY에 문자 내용을 직접 반환(템플릿 x)
  • viewResolver 대신에 HttpMessageConverter가 동작
  • 기본 문자처리: StringHttpMessageConverter
  • 기본 객체처리: MappingJackson2HttpMessageConverter -> json으로 처리
    hello라는 객체를 리턴하므로 json형식으로 만들어서 반환해준다고 생각하면 될 것 같다.
profile
SW Engineer

0개의 댓글