因为当前业务需求,页面需要有个超链接需要获取当前模板的访问路径。
举个例子,假如当前模板访问路径是localhost:8080/action/index,我在页面需要获取这个路径,请大家帮忙。
<div th:text="${#httpServletRequest.requestURL}"></div>
如果url后面有参数,就添加
<div th:text="${#httpServletRequest.requestURL +'?'+ #httpServletRequest.queryString }"></div>