thymeleaf中js获取项目根路径

2019-06-19  本文已影响0人  舒尔诚

<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

上一篇 下一篇

猜你喜欢

热点阅读