更新時間:2022-03-14 10:28:51 來源:動力節(jié)點 瀏覽1459次
使用ajax提交時基本不支持跳轉(zhuǎn)網(wǎng)頁:
查詢解決方案是:
1.JS前臺是跳轉(zhuǎn);
2.后臺返回腳本:
struts2
struts.xml -->
< action name ="login" method ="login" class ="com.hope.action.LoginAction" >
< param name ="code" > string </ param >
< param name ="pass" > string </ param >
<結(jié)果名稱=“登錄”類型=“流” >
<參數(shù)名稱=“內(nèi)容類型” >
文本/html;charset=UTF-8
</ param >
< param name ="inputName" > json </ param >
</ result >
< result name ="error" type ="stream" >
< param name ="contentType" >
文本/html;charset=UTF-8
</ param >
< param name ="inputName" > json </ param >
</ result >
</ action >
Action.java
私有輸入流 json;
String url = "<script language=\"JavaScript\">window.top.location.href = \"../index.jsp\";</script>" ;
字節(jié)[] 數(shù)據(jù) = url.getBytes();
這個.json = new ByteArrayInputStream(data);
SpringMVC
輸出流 outputStream = null ;
字符串 url = "<script language=\"JavaScript\">window.top.location.href = \"../index.jsp\";</script>" ;
字節(jié)[] 數(shù)據(jù) = url.getBytes();
outputStream = response.getOutputStream();
outputStream.write(數(shù)據(jù));
輸出流.flush();
輸出流.close();
以上就是關(guān)于“Ajax跳轉(zhuǎn)頁面的提交方法”的介紹,大家如果想了解更相關(guān)知識,可以關(guān)注一下動力節(jié)點的Java在線學習,里面的課程內(nèi)容從入門到精通,通俗易懂,適合沒有基礎(chǔ)的小伙伴學習,希望對大家能夠有所幫助。