日期:2014-05-20 浏览次数:20926 次
request.getContextPath()+路径
------解决方案--------------------
request.getContextPath()+"/test2/test2.jsp"
------解决方案--------------------
确实挺麻烦的,我试了也不行
这样可以
<script type="text/javascript">
var pathname=window.location.pathname;
var arr=pathname.split("/");
var proName=arr[1];
window.location.href="/"+proName+"/test2/test2.jsp";
</script>
------解决方案--------------------
没解决掉的话,你可以用这种方法:在js里做个action,让它到action里处理
var url = "***.do?method=abc"
------解决方案--------------------
有一种偷巧的办法:
你在JSP文件里面定义一个全局变量,比如 var baselocation;
<script language="javascript">
var baselocation='<%=request.getContextPath()%>';
</script>
后面你就可以用它了
------解决方案--------------------