java - Thymeleaf th:if expression not evaluating true -


i trying evaluate expression 2 strings, evaluating true well, when used within th:if not working expected.

the below code trying

<div th:with="cntx=${#httpservletrequest.getrequesturi()}">    <li th:each="obj : ${list}" th:with="path=${obj.path}"                     th:if="${path == cntx}">     <span th:text="${obj.title}"></span>    </li> </div> 

the context above code,

i have list of objects contain link has displayed in 1 of objects. trying string equality th:if, expression here ${path == cntx} failing reason , not showing on final rendered page.

i checked path , uri values equal i.e /test path , /test cntx, evaluating true if print out using th:text. quite strange behaviour.

my guess if evaluated before th:with. try :

<th:block th:each="obj : ${list}" th:with="path=${obj.path}">   <li  th:if="${path == cntx}">...</li> </th:block> 

however, me, have print kind of useful exception (like: variable path not found).


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -