user3012685
user3012685

Reputation: 21

how to in include external js file in thymeleaf

I have very new to the thymeleaf, and I am trying to include:

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

but i am getting the error like:

HTTP Status 500 - Request processing failed; nested exception is org.thymeleaf.exceptions. TemplateInputException: Exception parsing document: template="test", line 5 - column 103

and the line number five is the above script So how to resolve this problem?

Upvotes: 1

Views: 1994

Answers (2)

user3012685
user3012685

Reputation: 21

You need to include &amp in place of & and put ; at the end as shown below:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false&libraries=places"></script>

Upvotes: 1

ciri-cuervo
ciri-cuervo

Reputation: 1756

In this example you can see how to add path variables to a src URL and also how to read environment properties.

<script th:src="@{https://maps.googleapis.com/maps/api/js(key=${googleApiKey}, libraries=places, sensor=false)}"
        th:with="googleApiKey=${@environment.getProperty('googleapis.api_key')}"
        src="https://maps.googleapis.com/maps/api/js"></script>

Upvotes: 1

Related Questions