springboot (6)-홈페이지 사용자 지정 방법, 템플릿 엔진 Thymeleaf

1 홈페이지 커스터마이징 방법

소스 코드는 실행 프로세스를 보여줍니다.
여기에 사진 설명 삽입
여기에 사진 설명 삽입

2 템플릿 엔진

https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/htmlsingle/#using-boot
pom.xml의 종속성 가져 오기
우리는 모두 버전 3.x로 개발되었습니다.

	<dependency>
			<groupId>org.thymeleaf</groupId>
			<artifactId>thymeleaf-spring5</artifactId>
		</dependency>
		<dependency>
			<groupId>org.thymeleaf.extras</groupId>
			<artifactId>thymeleaf-extras-java8time</artifactId>
		</dependency>

테스트
여기에 사진 설명 삽입
를 사용해야하는 thymeleaf한 해당 종속성 만 가져 오면 됩니다! html 파일을 templates
여기에 사진 설명 삽입
테스트 할 것
여기에 사진 설명 삽입입니다.TestController.java

package com.zs.helloword.controller;

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

// 在templates目录下的页面 只能通过controller来跳转
// 需要模板引擎的支持 thymeleaf
@Controller // 跳到一个页面
public class TestController {
    
    
    @RequestMapping("/test")
    public String test(Model model) {
    
    
        model.addAttribute("msg","hello,springboot!");
        return "test";
    }
}

테스트 th:text th:utext
여기에 사진 설명 삽입
테스트th:each
여기에 사진 설명 삽입

추천

출처blog.csdn.net/zs18753479279/article/details/112510346