getRequestURI和getRequestURL

2019-07-23  本文已影响0人  塔塔斯坦

请求 http://localhost:8080/ServletDemo/abc/../hello;xyz

在ServletDemo的/hello响应函数中,

request.getRequestURI()  --->  /ServletDemo/abc/../hello;xyz

request.getRequestURL()  --->  http://localhost:8080/ServletDemo/abc/../hello;xyz

request.getContextPath() --->  /ServletDemo

request.getServletPath() --->  /hello

request.getPathInfo()    --->  null 其实是除了getContextPath和getServletPath的其他路径部分,是实际路径相对于servlet的配置路径(*通配)多出来的部分

----------------------

所以实际上getRequestURI和getRequestURL用来做路径校验的话是有风险的

上一篇 下一篇

猜你喜欢

热点阅读