Spring(基礎)-21.12.08


1. Welcome Page

  • http://localhost:8080/お願い
  • 静的フォルダでインデックスファイルを検索(static/index.html)
  • 静的フォルダにない場合はtemplatesフォルダでインデックスファイルを検索(templates/index.html)
  • 2.胸腺テンプレートエンジン

    @Controller
    public class HelloController {
    	@GetMapping("hello")
    	public String hello(Model model) {
       		model.addAttribute("data", "hello!!"); // thymeleaf 에 data 변수명으로 값 전달
    		return "hello"; // templates/hello.html
            }
    }
  • http://localhost:8080/helloお願い
  • コントローラがテキストを戻り値として返すと、ビューリフレッシュが画面を検索して処理する
    ( templates/hello.html )
  • ばねガイドテンプレートエンジンデフォルトviewNameマッピング
  • resources: templates/+{ViewName}+ .html
  • 3.構築および実行

  • 該当項目へ移動
  • ./gradlew build
  • cd build/libs
  • java -jar hello-spring-0.0.1-SNAPSHOT.jar
  • 実行確認