Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thymeleaf rendering error when using ampersand in script tag

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!

like image 275
Frans Filasta Pratama Avatar asked Feb 18 '16 03:02

Frans Filasta Pratama


1 Answers

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.

like image 114
Aboodz Avatar answered Oct 06 '22 17:10

Aboodz