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="??" />
Request parameters can be easily accessed in Thymeleaf views. Request parameters are passed from the client to server like: https://example.com/query?q=Thymeleaf+Is+Great! In the above example if parameter q is not present, empty string will be displayed in the above paragraph otherwise the value of q will be shown.
Another way of accessing request parameters in thymeleaf is by using #httpServletRequest utility object which gives direct access to javax. servlet. http. HttpServletRequest object.
You can use the "th:text=#{variable}" to print a variable in the Thymeleaf.
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}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With