use contextPath in Thymeleaf

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

use contextPath in Thymeleaf

NagarajuO
Hi,

Does anyone knows how to use contextPath in Thymeleaf?

Regards,
Nagaraju
Reply | Threaded
Open this post in threaded view
|

Re: use contextPath in Thymeleaf

yvanavermaet
Hi

I'm not really familiar with it, but give us some context why you're looking into contextPath. Do you want to build a feature, are you experiencing a bug, ...? What are you trying to achieve?

Kind regards,
Yannick
Reply | Threaded
Open this post in threaded view
|

Re: use contextPath in Thymeleaf

NagarajuO
Hi,

Thanks for quick reply.

As part of migration to spring boot, I am replacing jsps with Thymeleaf. In jsp's we form's with action to get request context to post multipart file content. During migration i need to change with respect to Thymeleaf synatx.

Regards,
Nagaraju
Reply | Threaded
Open this post in threaded view
|

Re: use contextPath in Thymeleaf

yvanavermaet
Hi

You could use Context Relative URLs: http://www.thymeleaf.org/doc/articles/standardurlsyntax.html
==> th:action="@{/my-url}"

Hope that helps.

Kind regards,
Yannick
Reply | Threaded
Open this post in threaded view
|

Re: use contextPath in Thymeleaf

NagarajuO
Hi,

i tried as below but it did not work for me.

@{/execute/zipfile}

The URL is updated as below,
http://localhost:14080/initialload/@%7B/execute/zipfile%7D

Regards,
Nagaraju
Reply | Threaded
Open this post in threaded view
|

Re: use contextPath in Thymeleaf

yvanavermaet
Hi

Did you write this in the th:action attribute? Looks to me as if you added it to the action attribute

Example: <form th:action="@{/execute/zipfile}">

Kind regards,
Yannick