How to use condition in form action thymeleaf

824 Views Asked by At

i want to use ternary, for my action form in thymeleaf like this, is that possible? i try this one, but doesn't work

<form th:action=**"${action} == UH ? @{/summary/approvalDH} : ${action} == BOD ? @{/summary/approvalBOD} : @{/summary/approvalUH}"** name="myForm" onsubmit="return validateForm()" method="post" >

but if there is one condition its work

<form th:action=**"${action} == 'UH' ? @{/summary/approvalDH} : @{/summary/approvalUH}"** name="myForm" onsubmit="return validateForm()" method="post" >
1

There are 1 best solutions below

1
Juan Carlos Guibovich On BEST ANSWER

Use parenthesis:

        th:action=**"${action} == UH ?  (${action} == BOD ?@{/summary/approvalBOD} : @{/summary/approvalUH}):@{/summary/approvalDH} "