web获取路径
来源:互联网 发布:新加坡国家顶级域名 编辑:程序博客网 时间:2024/05/16 12:54
我访问的是http://localhost:8080/bottleBlog/useless/path.jsp这个网址,这是如下API得到的结果:
<h3> getServletPath=<%= request.getServletPath()%><br> getContextPath=<%= request.getContextPath()%><br><!-- The method getRealPath(String) from the type ServletRequest is deprecated --> <%-- getRealPath=<%= request.getRealPath("/")%><br> --%> getRealPath=<%= request.getServletContext().getRealPath("/")%><br> getServletContext=<%= request.getServletContext()%><br> getRequestURI=<%= request.getRequestURI()%><br> getRequestURL=<%= request.getRequestURL()%><br> </h3>
getServletPath=/useless/path.jspgetContextPath=/bottleBloggetRealPath=D:\JavaEEWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\bottleBloggetServletContext=org.apache.catalina.core.ApplicationContextFacade@4a272157getRequestURI=/bottleBlog/useless/path.jspgetRequestURL=http://localhost:8080/bottleBlog/useless/path.jsp
其中URI和URL的区别可以见传送门
其余的几个API的话,我自己是讲不清的,所以还是上API文档吧。
String javax.servlet.http.HttpServletRequest.getServletPath()Returns: a String containing the name or path of the servlet being called, as specified in the request URL, decoded, or an empty string if the servlet used to process the request is matched using the "/*" pattern.
返回当前URL请求调用servlet的一部分。
String javax.servlet.http.HttpServletRequest.getContextPath()Returns: a String specifying the portion of the request URI that indicates the context of the request
指定请求URI的一部分的字符串,表示请求的上下文。
String javax.servlet.ServletContext.getRealPath(String path)Returns a String containing the real path for a given virtual path.
返回给出的虚拟路径的真实路径。
1 0
- Silverlight获取Web路径
- j2ee获取web路径
- WEB 获取文件路径
- java web 获取路径
- 获取Web项目路径
- 获取Web项目路径
- web项目路径获取
- web获取路径
- Java获取WEB目录路径
- Java获取WEB目录路径
- java web 各种获取路径
- jsp 获取web程序路径
- Java获取WEB目录路径
- Java获取WEB目录路径
- Java Web 获取根路径
- java web 获取各种路径
- web项目中的路径获取
- C#中web获取路径
- 点线面的融会贯通学习方法探讨
- 小白初装SQL Server 2008遇到的问题
- 跟小博老师一起学Servlet ——Servlet之HttpServletResponse
- 使用Notepad++批量转换源代码编码方式
- Navicat for MySQL触发器更新和插入操作
- web获取路径
- ZooKeeper理解
- jieba 分词自定义词典问题
- iOS开发系列--UITableView全面解析
- Face Detection with the Faster R-CNN(数据集标注对比研究报告 )
- 计算机图形学 OPENGL学习
- 页面显示空格(nbsp)的兼容问题
- Glide:调整图片大小
- 黄庭坚的《清明》