java为什么HttpServletRequest会截断#字符上的url输入?
下面的servlet读取url路径参数。
问题:如果输入包含特殊字符,例如我发现#
,则字符串被截断
@RestController
public class MyServlet {
@GetMapping("/hash")
@ApiIgnore
public String hash(HttpServletRequest req) {
String pw = req.getPathInfo(); //asdfgh
}
}
`localhost:8080/hash/asdfgh#jkl`
问题:我如何以本机方式传递输入参数
# 1 楼答案
从
#
开始的部分不会发送到servlet或被servlet接收这是一种仅从客户端(浏览器)使用的信息,不会产生任何影响 URI的一部分
该RFC2396确实指出: