springboot整合Thymeleaf

添加依赖:

        <!-- 整合视图层技术-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

创建html:

 代码:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    hello!!!
</body>
</html>

创建controller:

 代码:

package com.xys.springnew.controller;

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

@Controller
@RequestMapping("page")
public class PageController {

    @RequestMapping("hello")
    public String hello() {
        return "hello";
    }
}

访问url:

 结束。

posted @ 2020-12-22 14:03  丙炎  阅读(233)  评论(0)    收藏  举报