springboot集合thymeleaf

springboot集合thymeleaf,第1张

1、添加依赖

        
            org.springframework.boot
            spring-boot-starter-thymeleaf
        

2、写Controller

@Controller
public class IndexController {
    @RequestMapping(value = "/index")
    public String index(Model model){
        model.addAttribute("data","Springboot 框架集成 Thymeleaf");
        return"index";
    }
}

3、写html文件

在html中添加




    
    Title


xxx

4、写主配置文件

关闭缓存

#设置thymeleaf模板引擎的缓存
spring.thymeleaf.cache=false

#设置thymeleaf模板引擎的前后缀
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html

5、更改工件配置文件

修改为 

Update resources

Update resources

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/729740.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存