美文网首页
thymeleaf中js获取项目根路径

thymeleaf中js获取项目根路径

作者: 舒尔诚 | 来源:发表于2019-06-19 11:18 被阅读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

相关文章

网友评论

      本文标题:thymeleaf中js获取项目根路径

      本文链接:https://www.haomeiwen.com/subject/ciuhqctx.html