thymeleaf直接调用Spring Bean中定义的方法

thymeleaf中可以使用表达式工具对象,通过@符号直接调Spring Bean中定义的方法

Spring Bean

java 复制代码
@Component
public class InvokeMethodBean {
 public String fun() {	
 	return "fun";
 }
}

thymeleaf中调用

java 复制代码
<div th:text="${@invokeMethodBean.fun()}"></div>
相关推荐
极光代码工作室27 分钟前
基于SpringBoot的在线博客系统
java·springboot·web开发·后端开发
我是唐青枫38 分钟前
Java Spring Security 实战详解:从登录认证到 JWT 权限控制
java·spring
用户7713970207061 小时前
我在项目里发现了一个“神秘文件“——.editorconfig
后端
盏灯1 小时前
mac 外接磁盘,热更新失效
前端·后端
ihuyigui1 小时前
海外签收通知短信接口
android·java·开发语言·前端·数据库·后端
海棠Flower未眠1 小时前
SpringBoot 消息死信队列(荣耀典藏版)
java·数据库·spring boot
腾渊信息科技公司1 小时前
Spring Boot + TDengine:工业视觉检测数据实时同步方案实战
spring boot·后端·tdengine
空中湖1 小时前
Spring AI 多模态实战:让 AI 看图、听声音、生成图片
人工智能·spring·语音识别
暖和_白开水2 小时前
数据分析agent (七):contextvars 模块上下文request_id
java·前端·数据分析
用户40966601317512 小时前
MyBatis、MyBatis-Plus、通用 Mapper:一张图说清三者的血缘关系
后端