【发布时间】:2018-06-16 04:18:46
【问题描述】:
我正在使用 thymeleaf,我希望我的链接是: http://localhost:8080/item?id=1/cmets
我试过这个选项:
<a th:href="@{item#/comments(id=${item.id})}" th:text="${item.title}"></a>
它给了我:
http://localhost:8080/item?id=1#/cmets
但是符号 # 是多余的。
我不确定我是否在控制器中正确接收到它:
@GetMapping(value = "/item/comments")
public String showItemComments(@RequestParam Long id, Model model) {
// do something...
}
我将不胜感激。
【问题讨论】:
-
您正在尝试在查询参数中使用路径参数。这没有多大意义。只需使用
/items/1/comments。一旦以?开始查询字符串,就不能再添加路径参数了。 -
感谢您的帮助。
标签: java spring spring-mvc spring-boot thymeleaf