사용자 액션 흐름

 

1. Broswer 를 실행한다.

2. Broswer 주소창에 http://localhost:8080/hi 를 입력하고 접속한다.

3. Broswer Screen Shot

 

 

 

- Controller 샘플 코드 스크린 샷 -

 

 

- Controller & Model 샘플 코드 -

package com.yym.sample001.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller     //  Spring boot MVC 문법 - 컨트롤러 선언
public class FirstController {

	//	--------------------------------------------------------
	//  - Spring boot MVC 문법 - 출력 URL 경로 설정 ( 일종의 라우팅 설정 )	
    //  - 즉 http://locahost:8080/hi 접속이 발생했을때 수행될 함수에 대한 정의를
    //    @GetMapping("hi") 으로 선언하여 사용
    //	--------------------------------------------------------
    
    @GetMapping("hi")   
    //  모델 객체를 - 함수( 메소드의 ) 파라미터로 받아서 처리
    public String niceTomeetYou(Model model){
        
        model.addAttribute("username","111");
        return "greetings"; //  View 영역에 대한 처리 - templates/greetings.mustache -> 브라우져로 리턴
    }
}

 

 

 

- template 샘플 코드 스크린 샷 - 

 

- template 샘플 코드 - 

<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<h1>{{username}} 님 반갑습니다.</h1>
</body>
</html>