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