最近项目需要在JS中跳转到指定的Action。通过不断的实验和查资料,终于成功。Java SSH2 架构下,正常 配置Action完毕。在xxx.jsp下
<script type="text/javascript">
window.location=" <%=request.getContextPath()%/namespace/actionname> ";
例如:window.location=" <%=request.getContextPath()%>/user/ResAction> ";
其中ResAction是配置文件中的Action名称。
</script>
通过以上就可实现了跳转到指定的Action。
但是让我比较纳闷的一点问题是:
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
本文介绍了一种在JavaScript中实现跳转至指定Action的方法,适用于JavaSSH2架构下的项目。通过设置window.location属性,结合request.getContextPath()获取上下文路径,实现页面跳转。
4万+

被折叠的 条评论
为什么被折叠?



