Skip to main content

2.Spring MVC

·131 words·1 min· loading
Table of Contents
FIrstSPring - This article is part of a series.
Part 4: This Article

MVC란?
#

MODEL - VIEW - Controller

Model
#

  • 데이터를 가진 객체
  • 컨트롤러와 뷰에 통보

View
#

  • HTML/CSS/JS

Controller
#

  • 사용자의 접근에 따라 Model을 만들고, 이를 View에 반영시켜 사용자에게 전달

Spring MVC
#

servlet-context.xml
#

appServlet폴더 내의, MVC 설정만 분리하기 위한 파일

annotation
#

annotationdescusing
@controller스프링 컨트롤러 객체임 명시클래스
@RequestMapping특정 URL에 매핑클래스,메소드
@RequestParamreq에서 특정한 파라미터 추출파라미터
@RequestHeaderreq에서 특정 헤더 추출파라미터
@PathVariabel현재 URL에서 정보 추출파라미터
@CookieValue쿠키값 추출파라미터
@ModelAttribute자동으로 해당 객체의 뷰까지 전달메소드,파라미터
@SessionAttribute세션상에서 모델 정보 유지클래스
@Responsebody리턴값 그대로 응답메소드,리턴타입
@RepositoryDAO(Data access object)클래스
@Service서비스객체클래스

return type
#

void
#

매핑된 이름.jsp 반환

String
#

문자열+.jsp 반환 return redirect: + 문자열 을 통해 redirect 가능

Object
#

객체를 json으로 변환

FIrstSPring - This article is part of a series.
Part 4: This Article