thymethy:springboot启动后访问templates子文件夹下html

thymethy模板访问页面路径默认设置如下

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html

当/template/index.xml时

@Controller

public class HomeController {

    @RequestMapping("/") //若是@RequestMapping("/home"),则浏览器访问http://localhost:8080/home路径
    public String hello() {
        return "home";
    }

}

当/template/pages/home.xml时

@Controller

public class HomeController {

    @RequestMapping("/")
    public String hello() {
        return "pages/home";//子文件pages下
    }

}

浏览器中访问http://localhost:8080即可

你可能感兴趣的:(前端)