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