Problem with anchor

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

Problem with anchor

Zemi
Administrator
Hello,

I'm trying to set a link with an anchor, as in the following URL
   http://www.w3.org/TR/html4/struct/links.html#h-12.2.1

First, I tried to use the th:href processor

        < a th:href="@{/footer.html#terms}" >Terms< /a >

but it throws the following error:

       ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][3] Exception processing template "index.html": Could not parse value: "@{/footer.html#terms}"

Then I tried the th:attrappend processor
          < a th:href="@{/footer.html}" th:attrappend="href='#terms'" >Terms< /a >
but it does nothing (maybe I'm not writing the right syntax).

How do I write this kind of link?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with anchor

danielfernandez
Administrator
Zemi wrote
Hello,

I'm trying to set a link with an anchor, as in the following URL
   http://www.w3.org/TR/html4/struct/links.html#h-12.2.1

First, I tried to use the th:href processor

        < a th:href="@{/footer.html#terms}" >Terms< /a >

but it throws the following error:

       ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][3] Exception processing template "index.html": Could not parse value: "@{/footer.html#terms}"

Then I tried the th:attrappend processor
          < a th:href="@{/footer.html}" th:attrappend="href='#terms'" >Terms< /a >
but it does nothing (maybe I'm not writing the right syntax).

How do I write this kind of link?
This is --was-- a bug. The # character was not being correctly recognized as a valid URL character, and therefore you got a "could not parse" error.

Your "attrappend" solution did not work because "th:attrappend" has a precedence of 900, whereas "th:href" has a precedence of 1000, which means that "th:href" executes after th:attrappend, and so when the latter executes there is nothing yet to append its value to.

I've just uploaded snapshot 1.0.1-20110718.183033-1 that fixes this problem. Remember that, for testing it, you should configure the Sonatype OSS Snapshot repositories and set the Thymeleaf version in your dependencies to 1.0.1-SNAPSHOT.

If everything is OK, this fix will go into a future 1.0.1 version.

Thanks,
Daniel.

Reply | Threaded
Open this post in threaded view
|

Re: Problem with anchor

Zemi
Administrator
Thank you very much for your extremely fast response.

I've just successfully checked the bugfix with the 1.0.1-SNAPSHOT version.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with anchor

pier1287
Hi,  
I'm an happy user of thymeleaf, but today i have found this bug on anchor href.
The version that i'm using is thymeleaf-2.1.4.RELEASE .
the error is this:

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Mar 24 14:49:19 CET 2016
There was an unexpected error (type=Internal Server Error, status=500).
Could not parse as expression: "#collapse[__${iterationStatus.index}__]" (tp/tpform/tp_iecomparables:28)

Pierluigi,
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Problem with anchor

mikovirgoez
In reply to this post by Zemi
Thank you admin, this very help me. :)