Converting a JSP to thymeleaf

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting a JSP to thymeleaf

Eric Francis
I'm trying to mimic this:
<c:url value="/login/loginAccess.do" var="loginURL" scope="request">

Will this do the trick?
< span th:with="loginURL=/login/loginAccess.do" th:scope="request">
Reply | Threaded
Open this post in threaded view
|

Re: Converting a JSP to thymeleaf

Eric Francis
Or really, Is there a better way to handle c:url with thymeleaf?
Reply | Threaded
Open this post in threaded view
|

Re: Converting a JSP to thymeleaf

Eric Francis
I'm trying to convert this bit of code:

<c:url value="/login.html" var="loginURL" scope="request">
  <c:param name="uri" value="/login.html"/>
  <c:param name="previousPage" value="${PREVIOUS_PAGE}"/>
  <c:if test="${null != payment}">
    <c:param name="payment" value="${payment}"/>
  </c:if>
</c:url>

So with thymeleaf: I need to construct the URL and set the variable to request scope. This is what I have so far:

< a th:with="loginURL=@(~/login.html(uri=/login.html
                ,previousPage=${PREVIOUS_PAGE_PATH})"
     th:scope="request">
< /a>

How can I execute an if statement?
Does th:scope correctly set the scope?
Reply | Threaded
Open this post in threaded view
|

Re: Converting a JSP to thymeleaf

Zemi
Administrator
The scope of a variable defined with th:with is the DOM inside, there is no th:scope or any other tag to control it.

About the syntax, I'm not sure about you want to achieve, but maybe is
    < a th:href="@(/login.html(uri=/login.html, previousPage=${PREVIOUS_PAGE_PATH}, payment=${payment})">Login</ a>