Java/Spring

MVC와 템플릿 엔진

본명은이점례 2021. 6. 29. 14:32
728x90

MVC : Model View Controller

 

@RequestParam() : 파라미터 받기

 

 

이런 식으로 작성하면 오류가 날 것

8080/hello-mvc에 ?name=spring이란 값을 주면 hello-templates.html로 넘어가 정상적으로 실행

required=true가 default값으로 설정되어 있고 false로 주면 값을 넘기지 않아도 된다.

 

8080/hello-mvc?name=spring -> name = spring이란 값을 주면 "name"이란 키, value값(name)에 spring이 저장된다.

이를 모델로 넘기고 hello-templates에 도달하면, 모델에서 값을 꺼내와  ${name}를 변환하여 보여준다.

 

 

 

hello-mvc // viewResolver를 거침

728x90