【Java】request.getContextPath()备忘
2017-10-24 17:10
148 查看
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
request.getScheme()可以返回当前页面使用的协议;默认返回http,SSL时返回https;
request.getServerName()可以返回当前页面所在的服务器的名字;
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是项目在服务器上发布的 端口,或者在本地tomcat容器运行时发布的端口,我用的是8081;
request.getContextPath()可以返回当前页面所在的应用的名字;
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
request.getScheme()可以返回当前页面使用的协议;默认返回http,SSL时返回https;
request.getServerName()可以返回当前页面所在的服务器的名字;
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是项目在服务器上发布的 端口,或者在本地tomcat容器运行时发布的端口,我用的是8081;
request.getContextPath()可以返回当前页面所在的应用的名字;
相关文章推荐
- 【javaweb:cookie】cookie.setPath("/"+request.getContextPath())这样写是错误的!!!
- request.getContextPath()用el表达式怎么写,绝对路径:request.getRealPath
- request.getcontextPath() 详解
- String path = request.getContextPath
- jsp获取相对路径网址的方法 request.getContextPath()
- getContextPath、getServletPath、getRequestURI的区别
- 关于request.getScheme()、request.getContextPath()
- Servlet中getContextPath、getServletPath、getRequestURI、getRealPath等区别
- <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getSe
- Request中getContextPath、getServletPath、getRequestURI、request.getRealPath的区别
- getContextPath、getServletPath、getRequestURI的区别
- request.getContextPath()用el表达式怎么写,绝对路径:request.getRealPath
- Request中getContextPath、getServletPath、getRequestURI、getRealPath
- request.getcontextPath() 详解
- getContextPath、getServletPath、getRequestURI、getRealPath的区别
- getContextPath、getServletPath、getRequestURI的区别
- ${pageContext.request.contextPath}|request.getContextPath() 项目路径怎么在js(jquery)中获得
- Request中getContextPath、getServletPath、getRequestURI、getRequestURL、getRealPath的区别
- String path = request.getContextPath(....拼装当前网页的相对路径
- getContextPath、getServletPath、getRequestURI的区别