在工具类中加入@Component注解即可。
@Component
public class MessageUtil {
public String getMsg(String param) {
if ("test".equals(param)) {
return "test success";
}
return "test failed";
}
}
Html中调用工具类使用@工具类名.方法名即可
需要注意的是类名首字母需要小写(Idea会提示)
<input th:value="${@messageUtil.getMsg('test')}"><br>