2013-11-22 68 views
1

外部js文件我有很新的thymeleaf,和我想包括:如何在包括thymeleaf

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

,但我得到的錯誤,如:

HTTP狀態500 - 請求處理失敗;嵌套異常是org.thymeleaf.exceptions的 。 TemplateInputException:異常解析 文件:模板=「測試」,第5行 - 列103

和行號五是上面的腳本那麼如何解決這個問題呢?

回答

1

你需要包括&安培代替&並放;在低於

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

1

去年一樣顯示在這個例子中,你可以看到如何路徑變量添加到src網址,以及如何閱讀環境屬性。

<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>