30

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

public final static int PROJECT_NAME_MAX_LENGTH = 255;

how to type:

<input type="text" th:maxlength="??" />
Cichy
  • 1,319
  • 3
  • 20
  • 36

1 Answers1

54

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}" />
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724