[英]In Spring Boot, can we pass anchor tag, as a variable, through URL like @PathVariable or @RequestParam?
I would like to use URL http://localhost:8080/blog#section & obtain #section as a variable in getBlog() method.我想使用 URL http://localhost:8080/blog#section 并获取 #section 作为 getBlog() 方法中的变量。
// localhost:8080/blog#section
@GetMapping("/blog/{section}")
public String getBlog(Model model, @PathVariable("section") String section){
return "blog" + section; // localhost:8080/blog#section
}
The #section part is never sent to server ( see this answer ),so what you are demanding is impossible. #section部分永远不会发送到服务器( 请参阅此答案),因此您的要求是不可能的。
In fact #section is used for browser to locate the content of a web page, it's not used for server to decide which content to return.实际上#section用于浏览器定位网页的内容,而不是用于服务器决定返回哪些内容。
What you are demanding can be easyily achieved with a query like localhost:8080/blog?section=?
使用
localhost:8080/blog?section=?
类的查询可以轻松实现您的要求localhost:8080/blog?section=?
or a url path like localhost:8080/blog/section
或者像
localhost:8080/blog/section
这样的 url 路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.