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