首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >2.新建项目-thymeleaf

2.新建项目-thymeleaf

作者头像
Yuyy
发布2022-06-28 19:37:15
发布2022-06-28 19:37:15
7820
举报

本文最后更新于 912 天前,其中的信息可能已经有所发展或是发生改变。

1. pom.xml

代码语言:javascript
复制
    <dependencies>
        <!-- springboot启动器 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- thymeleaf启动器 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>

2. html

视图文件存放的目录:src/main/resource/templates 注:该目录是安全的,意味着该目录下的内容不允许外界直接访问,防止视图文件未经过渲染就展现

代码语言:javascript
复制
    <span th:text="Yuyy"></span>
    <hr>
    <span th:text="msg"></span>

3. controller

代码语言:javascript
复制
    @RequestMapping("show")
    public String showInfo(Model model){
        model.addAttribute("msg", "hello thymeleaf");
        return "index";
    }

4. 异常

由于旧版本的thymeleaf对渲染的html文件的语法要求严谨,所有标签必须具备结束标签

产生异常

处理异常

5. 成功

Post Views: 367

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-12-29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. pom.xml
  • 2. html
  • 3. controller
  • 4. 异常
  • 5. 成功
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档