I have below code in a web page in Spring Boot 2 web app:
<div data-th-fragment="head-section">
<div> blah </div>
<script data-th-inline="javascript">
var url = [[${#request.requestURL} ]];
var country = [[${#locale.country}]]
</script>
</div>
Thymeleaf throws error that says cannot get requestURL on null while it correctly gets the locale. Thymeleaf 3 official documentation says #request and #locale are valid objects in web context.
How to fix this issue?