Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@baybatu
Last active August 13, 2020 11:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baybatu/06ac9d3ab2ccc3af0532e42320fd0633 to your computer and use it in GitHub Desktop.
Save baybatu/06ac9d3ab2ccc3af0532e42320fd0633 to your computer and use it in GitHub Desktop.
Accessing static constant values from Thymeleaf templates.

From expercise project:

<td>
  <input class="form-control" type="text" name="inputValue"
          th:maxlength="${T(com.expercise.utils.Constants).MAX_TESTCASE_VALUE_LENGTH}" />
</td>
@AlexanderFillbrunn
Copy link

AlexanderFillbrunn commented May 22, 2018

Without Spring and SpEL this can be achieved like this:

<td>
    <input class="form-control" type="text" name="inputValue"
        th:maxlength="${@com.expercise.utils.Constants@MAX_TESTCASE_VALUE_LENGTH}" />
</td>

(from the OGNL documentation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment