2015-04-03 142 views
1

我需要得到當前 URL的某些部分。 我已經URI地址,如:在Thymeleaf中獲取URL部件

/ 
/about 
/users/john 
/users/doe 

我在尋找一種方式來從Thymeleaf得到字符串/users

這個${#httpServletRequest.requestURI}返回整個URI。

回答

3

在Thymeleaf html頁面

<a th:href="@{'/about'}">About</a> 

控制器

@RequestMapping(value="/about",method=RequestMethod.GET) 
    public String about(ModelMap model) { 
}