<script th:inline="javascript" type="text/javascript">
var ctxPath = [[@{/}]];
var ctxPath = /*[[@{/}]]*/'';
var ctxPath=[[${#httpServletRequest.getContextPath()}]];
</script>
在项目中的例子
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('�鿴��ά��')" />
</head>
<body class="gray-bg">
<div id="qrcode" style="text-align: center;"></div>
<th:block th:include="include :: footer" />
<script th:src="@{/js/jquery-qrcode-1.0.min.js}"></script>
<script th:inline="javascript">
$(function(){
var actId = [[${actId}]];
var basePath = /*[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]*/;
var url = basePath + "/business/activity/toSign/"+actId;
console.log(url);
jQuery('#qrcode').qrcode({ width: 400, height: 400, text: url });
})
</script>
</body>
</html>