美文网首页
getRequestURI和getRequestURL

getRequestURI和getRequestURL

作者: 塔塔斯坦 | 来源:发表于2019-07-23 16:21 被阅读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用来做路径校验的话是有风险的

相关文章

网友评论

      本文标题:getRequestURI和getRequestURL

      本文链接:https://www.haomeiwen.com/subject/slralctx.html