转载【js中获取 <%=request.getContextPath()%>】
来源:互联网 发布:淘宝评价多久生效 编辑:程序博客网 时间:2024/06/05 00:52
在jsp中获取context path或者basePath 是很容易的。在javascript中也可以获取,并且有的时候也很有必要。
在JSP中这样使用
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
在单独的javascript中不能使用<%= basePath%>类似这样的java script所以,只能用javascript来获取此context path.
可以用下面的代码来实现。
var localObj = window.location;var contextPath = localObj.pathname.split("/")[1];var basePath = localObj.protocol+"//"+localObj.host+"/"+contextPath;var server_context=basePath;
原文地址:http://hexudonghot.blog.163.com/blog/static/532043422012112264411234/
0 0
- 转载【js中获取 <%=request.getContextPath()%>】
- [js]js中获取 <%=request.getContextPath()%>
- js中获取 <%=request.getContextPath()%>
- js中获取 <%=request.getContextPath()%>
- js中获取 <%=request.getContextPath()%>
- request.getContextPath获取绝对路径
- 通过request.getContextPath获取绝对路径
- %=request.getContextPath() %解释
- <%=request.getContextPath()%>
- <%=request.getContextPath()%>
- String path = request.getContextPath();获取应用的上下文路径。
- ${pageContext.request.contextPath}|request.getContextPath() 项目路径怎么在js(jquery)中获得
- <%=request.getContextPath()%>的作用
- String path = request.getContextPath
- <%=request.getContextPath()%>的作用
- <%=request.getContextPath()%>的作用
- request.getContextPath()获取的是什么路径?
- request.getContextPath()获取的是什么路径?
- 面试题常用易错总结
- 织梦百度结构化数据地图提交插件常见问题及解决方案
- 关于Android4.0的Alertdialog对话框
- sql server 查询时显示新的列
- 马方:已部署遥控性小海船专门寻找黑匣子
- 转载【js中获取 <%=request.getContextPath()%>】
- 【OpenCV入门教程之三】 图像的载入,显示和输出 一站式完全解析
- Android View的onTouchEvent和OnTouch区别
- c++ STL的各种容器方法总结
- Unity3D开发之NGUI结合粒子系统的遮挡问题
- Linux 内核网络协议栈 ------ 清理重传队列中函数 tcp_clean_rtx_queue
- Giraph 基础介绍
- Silverlight——读取宿主web.config
- websphere端口