日期:2014-05-18  浏览次数:20696 次

怎样用SJ实现跳转兼容IE和FireFox啊?
项目结构如下。


Login.jsp 和 ZhuCe.jsp 在同一个包myjsp中
当前在Login.jsp页面中 
我用window.loaction.href="myjsp/ZhuCe.jsp" ; 在火狐和Opera中能够正常实现跳转 正常跳转到 http://localhost:8888/WebProject2/myjsp%5CZhuCe.jsp。

但是在IE中就不行了 。IE会跳转到http://localhost:8888/WebProject2/myjsp/myjsp/ZhuCe.jsp 错误

如果将window.loaction.href="myjsp/ZhuCe.jsp" ;改成window.loaction.href="ZhuCe.jsp" ;就能再IE中正常跳转,但是在火狐和Opera中就不行了。

用window.open("");和document.loaction.href="" 这两种方法都跟上面的效果一样.

这该怎么解决啊?

------解决方案--------------------
window.loaction.href = "${pageContext.request.contextPath}/myjsp/ZhuCe.jsp";
------解决方案--------------------
这不是浏览器跳转的问题,而是你自己没把相对地址、绝对地址,以及 Web 应用的 Context Path 搞清楚。
------解决方案--------------------
设一个<base>标签应可以可以了。
<%String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";%>
<base href="<%=basePath%>" />
------解决方案--------------------
设一个<base>标签应可以可以了。
<%String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";%>
<base href="<%=basePath%>" />