I am using the Thymeleaf Spring loading template engine to develop my web application. To rewrite url I use UrlRewriteFilter library .
My problem is that I was not able to rewrite the url to an absolute url. For example, if the script src value is configured in html as shown below
<script th:src="@{/js/jquery.js}"></script>
and rules defined in urlrewrite.xml as
<urlrewrite> <outbound-rule> <from>/js/jquery.js</from> <to>https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.js</to> </outbound-rule> </urlrewrite>
Expected Result:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.js"></script>
But it is generated as
<script src="/myapphttps://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.js"></script>
where / myapp is the root of the context. How to get rid of the context root and get only the absolute url that I configured.
source share