在 Spring Boot 应用程序中进行 get 操作时,
就像 api/getbooks/1 :它获取第一条记录。
对于 api/getbooks/@ :给出无效参数。
但是 api/getbooks/1#
:给出与 api/getbooks/1 相同的结果。
我怎样才能不接受#?
最佳答案
在维基百科上的URL片段文章中可以找到
The fragment identifier functions differently to the rest of the URI: its processing is exclusively client-side with no participation from the web server, ... When an agent requests a web resource from a Web server, the agent sends the URI to the server, but does not send the fragment
所以这基本上是预期的行为, # 以及之后的所有内容都不会发送到服务器。因此,两个查询的 URL 服务器获取的内容是相同的。
关于java - 当我们在 url 路径参数中传递 # 而不是 Integer 时,为什么它接受 '#' 而不是 Integer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55586362/