栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot——Thymeleaf常见属性-th:inline内敛文本text、内敛脚本javascript

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot——Thymeleaf常见属性-th:inline内敛文本text、内敛脚本javascript

引言

th:inline 有三个取值类型 (text, javascript 和 none),值为 none 什么都不做,没有效果

内敛文本(th:inline=”text”)内敛文本表达式不依赖于 html 标签,直接使用内敛表达式[[表达式]]即可获取动态数据,但必须要求在父级标签上加 th:inline = “text”属性

内敛脚本(th:inline=”javascript”)th:inline=”javascript”在 js 代码中获取后台的动态数据

代码举例

内敛文本和内敛脚本写在一起,对比学习

写一个controller类

package com.liuhaiyang.springboot.controller;

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

@Controller
public class UserController1 {
    @RequestMapping("inline")
    public String Inline(Model model){
        model.addAttribute("data","springboot inline");
        return "inline-test";
    }
}

写一个前端html页面 inline-test展示数据




    
    内敛表达式


    
内敛文本:th:inline="text" 数据:[[${data}]]
内敛脚本 th:inline="javascript" 帮助显示接收的数据

 核心配置文件

spring.thymeleaf.cache=false

启动入口类测试

 

 

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/322445.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号