HttpServletRequest常用获取URL相关的方法
2015-12-06 14:44
651 查看
1、request.getRequestURL()
返回的是完整的url,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数。
2、request.getRequestURI()
得到的是request URL的部分值,并且web容器没有decode过的
3、request.getContextPath()
返回 the context of the request.
4、request.getServletPath()
返回调用servlet的部分url.
5、request.getQueryString()
返回url路径后面的查询字符串
示例:
当前url:http://localhost:8080/CarsiLogCenter_new/idpstat.jsp?action=idp.sptopn
request.getRequestURL() http://localhost:8080/CarsiLogCenter_new/idpstat.jsp
request.getRequestURI() /CarsiLogCenter_new/idpstat.jsp
request.getContextPath()/CarsiLogCenter_new
request.getServletPath() /idpstat.jsp
request.getQueryString()action=idp.sptopn
返回的是完整的url,包括Http协议,端口号,servlet名字和映射路径,但它不包含请求参数。
2、request.getRequestURI()
得到的是request URL的部分值,并且web容器没有decode过的
3、request.getContextPath()
返回 the context of the request.
4、request.getServletPath()
返回调用servlet的部分url.
5、request.getQueryString()
返回url路径后面的查询字符串
示例:
当前url:http://localhost:8080/CarsiLogCenter_new/idpstat.jsp?action=idp.sptopn
request.getRequestURL() http://localhost:8080/CarsiLogCenter_new/idpstat.jsp
request.getRequestURI() /CarsiLogCenter_new/idpstat.jsp
request.getContextPath()/CarsiLogCenter_new
request.getServletPath() /idpstat.jsp
request.getQueryString()action=idp.sptopn
相关文章推荐
- Linux网络流量控制工具—Netem(可用于网络故障注入)
- <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>标签再使用时报错
- 为何1M的网络下载速度只有120k/s
- 解决RecyclerView中使用UIL加载网络图片,在刷新时出现闪烁问题
- uva 10779 Collectors Problem 网络流
- iOS开发:iOS9.0适配之http修改为https、Bitcode、Scheme白名单等问题
- 一个极其简单的用golang net写的tcpip echoserver
- linux安装nginx并设置https(openssl)
- Android下setLatestEventInfo警告、Handler警告、SimpleDateFormat警告http://www.piaoyi.org/mobile-app/Android-se
- Java网络编程示例
- javaweb学习总结(七)——HttpServletResponse对象(一)
- 【linux】网络编程基础(c语言编程)
- Stanford UFLDL教程 深度网络概览
- Stanford UFLDL教程 从自我学习到深层网络
- 计算机网络_3_应用层
- 网络安全防御全面封阻六种主要网络威胁
- 通过URL和HTTP请求获取网络资源两者有什么区别
- Android如何优雅的缓存网络图片
- TCP/IP详解之:IGMP和DNS
- Android之判断当前网络状态