Reputation: 71
I want to add google map javascript to a Thymeleaf template, like this:
https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places
It throws the exception:
org.xml.sax.SAXParseException; lineNumber: 209; columnNumber: 93; The reference to entity "key" must end with the ';' delimiter
I tried to change &
to &
but nothing changed.
Your help will be greatly appreciated. Thanks!
Upvotes: 7
Views: 2759
Reputation: 9145
You have some options:
1) Don't use the th:src
at all.
2) Since the URL is absolute, you can add it server-side using a static method:
<script th:src="${@urlService.getMapsUrl()}">...</script>
3) Use a rewrite filter.
Not sure whether the issue is corrected in Thymeleaf 3, but it could be worth upgrading quickly and taking a look.
Upvotes: 0
Reputation: 1584
Thymeleaf uses XML parser, and the character &
is considered a special character in XML. You have to replace &
with its XML equvilant &
.Your URL will be:
https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places
In thymeleaf 3, it won't be a problem since they wrote a new parser for thymeleaf.
Upvotes: 6
Reputation: 1554
It was a bug in Thymeleaf but it was fixed since 2.1.4.
Look at this issue. (The trouble described in this question).
Upvotes: 0