jsp路径使用

来源:互联网 发布:mysql的可视化界面 编辑:程序博客网 时间:2024/05/22 16:03
<%
String path = request.getContextPath();
// 获得项目完全路径(假设你的项目叫MyApp,那么获得到的地址就是 http://localhost:8080/MyApp/):
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.getSession().setAttribute("basePath",basePath);

%>

<script type="text/javascript">
var base = '<%=request.getSession().getAttribute("basePath")%>';
</script>

0 0
原创粉丝点击