spring boot thymeleaf 页面根路径获取和jsp获取的不同之处(粘贴即用)
不同之处已做高亮。
jsp 写法:
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-3.2.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/login.css"></link>
<script type="text/javascript"> $.ajax({ url : '${pageContext.request.contextPath }/syslogin/login'
)}
</script>
spring boot thymeleaf 写法:
<script type="text/javascript" th:src="@{/js/jquery-3.2.0.min.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/css/login.css}">
<script type="text/javascript"> $.ajax({ url : '[[@{/syslogin/login}]]' )} </script>