[英]Spring MVC, Thymeleaf URL
我有他的settings page
和控制器:
@RequestMapping(value = "/settings/password/change", method = RequestMethod.GET)
public String changePassword(Model model) {
return "account/changepassword";
}
在此頁面上有包含myaccount
鏈接的header
: <a class="link" th:href="${currentUser.nickname}"><li class="li">User profile</li></a>
但是,如果我打開標題上的settings page
鏈接有 URL: localhost:8080/settings/password/change/profilename
。 而不是這個,我需要像這樣的 URL: localhost:8080/profilename
。 我該怎么做?
你得到/settings/password/change/profilename
因為th:href="${currentUser.nickname}"
創建了一個當前路徑的相對 URL: <a href="profilename"/>
相反,嘗試使用這個Thymeleaf 語法來構建一個上下文相關的 URL:
<a th:href="@{/{profilename}(profilename=${currentUser.nickname})}">link</a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.