SPringBoot thymeleaf 入门例子

现在很流行 用thyeleaf 这种html 的页面替换传统的jsp 页面 。

所以我们也要来学习下,这个东西如何使用。下面写个简单的小例子了解 一下。

1: 首先创建出一个SpringBoot 的项目。勾选Thymeleaf 。

 

在对应的目录创建 hello.html  

 

 

 

 

package com.example.demo;


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

@Controller
public class HelloController {

    @RequestMapping("/hello")
    public  String hello(){

        return "hello";
    }


}

启动项目  访问  localhost:8080/hello

 

 

posted @ 2018-09-07 14:32  Cedar要减肥  阅读(458)  评论(0编辑  收藏  举报