JS 跳转到指定Action

来源:互联网 发布:2017网络新名词有哪些 编辑:程序博客网 时间:2024/05/18 03:43

最近项目需要在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 + "/";
%>