Thymeleaf construct URL with variable

As user482745 suggests in the comments (now deleted), the string concatenation I previously suggested <form th:action=”@{/mycontroller/} + ${type}”> will fail in some web contexts. Thymeleaf uses LinkExpression that resolves the @{..} expression. Internally, this uses HttpServletResponse#encodeURL(String). Its javadoc states For robust session tracking, all URLs emitted by a servlet should be run through this method. … Read more

Thymeleaf th:text – Put a text without removing HTML structures

I faced the same problem. The answer is th:inline=”text” This should solve your issue <h1 th:inline=”text” > [[${header.title}]] <small th:text=”${header.subtitle}”>Subtitle</small> </h1> or you can also use th:remove=”tag” <h1> <span th:text=”${header.title}” th:remove=”tag”>title</span> <small th:text=”${header.subtitle}” >Subtitle</small> </h1>

Thymeleaf: Concatenation – Could not parse as expression

But from what I see you have quite a simple error in syntax <p th:text=”${bean.field} + ‘!’ + ${bean.field}”>Static content</p> the correct syntax would look like <p th:text=”${bean.field + ‘!’ + bean.field}”>Static content</p> As a matter of fact, the syntax th:text=”‘static part’ + ${bean.field}” is equal to th:text=”${‘static part’ + bean.field}”. Try it out. Even … Read more

using data-* attribute with thymeleaf

Yes, th:attr to the rescue Thymeleaf documentation – Setting attribute values. For your scenario, this should do the job: <div th:attr=”data-el_id=${element.getId()}”> XML rules do not allow you to set an attribute twice in a tag, so you can’t have more than one th:attr in the same element. Note: If you want more that one attribute, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)