JS 跳轉到指定Action

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

發佈了33 篇原創文章 · 獲贊 2 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章