thymeleaf中可以使用表达式工具对象,通过@符号直接调Spring Bean中定义的方法
Spring Bean
java
@Component
public class InvokeMethodBean {
public String fun() {
return "fun";
}
}
thymeleaf中调用
java
<div th:text="${@invokeMethodBean.fun()}"></div>