从Thymeleaf进入课堂 [英] Access from Thymeleaf to class field

查看:118
本文介绍了从Thymeleaf进入课堂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Thymeleaf访问一些简单的POJO静态属性?例如:

How to access from Thymeleaf to some simple POJO static property ? For example:

public final static int PROJECT_NAME_MAX_LENGTH = 255;

如何输入:

<input type="text" th:maxlength="??" />


推荐答案

由于您使用的是Spring,百万美元可以访问EL由Spring提供。因此,你应该可以使用

Since you are using Spring, thymeleaf has access to the EL provided by Spring. You should therefore be able to use

<input type="text" th:maxlength="${T(com.example.MyType).PROJECT_NAME_MAX_LENGTH}" />

这篇关于从Thymeleaf进入课堂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆