<script type="text/javascript" th:inline="javascript" >
//thymeleaf 获取项目路径 contextPath th:inline="javascript"
/<![CDATA[/
var ctxPath = /[[@{/}]]/ '';
/]]>/
console.info("ctxPath ="+ctxPath);
</script>
其中 th:inline="javascript"不可少,这样获取的ctxPath 即为yml中配置的server.context-path
网友评论