7.주석

리얼브로·2023년 2월 24일
0

thymeleaf

목록 보기
7/10

7-1. 표준 HTML / XML 주석

  • 일반적인 HTML 처럼 <!-- 와 --> 사이의 구문을 주석으로 처리한다.

  • 타임리프 처리 후에도 템플릿에 남아 있다.

  • [요청] http://localhost:8080/ch0807/home0101

  • [컨트롤러 메서드]

    @GetMapping("ch0807/home0101")
    public String home0101(Model model) {
      model.addAttribute("msg", "Hello world!");
    
      return "ch0807/home0101";
    }
  • [뷰 파일]

    <html xmlns:th="http://www.thymeleaf.org">
    
    <head>
    	<title>Home</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
    	<!-- User info follows -->
    	<h1 th:text="${msg}">greeting</h1>
    </body>
    </html>
  • [응답 화면]

7-2. Thymeleaf 파서 수준 주석 블록

  • <!-- //--> 사이의 구문을 주석으로 처리한다.

  • 타임리프 처리 할 때 삭제된다.

  • [요청] http://localhost:8080/ch0807/home0201

  • [컨트롤러 메서드]

    @GetMapping("ch0807/home0201")
    public String home0201(Model model) {
      model.addAttribute("msg", "Hello world!");
    
      return "ch0807/home0201";
    }
  • [뷰 파일]

    <html xmlns:th="http://www.thymeleaf.org">
    
    <head>
    	<title>Home</title>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
    	<!--/* This code will be removed at Thymeleaf parsing time! */-->
    	<h1 th:text="${msg}">greeting</h1>
    </body>
    </html>
  • [응답 화면]

0개의 댓글