A.jsp頁面跳轉到B.jsp頁面,把A中的參數帶到B頁面中:
方法1:A頁面用隱藏值接受要傳遞的參數:
<input type="hidden" name="disId" value="" id="disId"/>
<input type="hidden" name="disName" value="" id="disName"/>
B頁面用request接受:
01 |
< p > |
02 |
<%= request.getParameter("disId")%> |
03 |
<% |
04 |
String str=null; |
05 |
if (request.getParameter("disName")!=null) { |
06 |
str= new String( request.getParameter("disName").getBytes("ISO-8859-1"),"utf-8");//解決亂碼 |
07 |
} |
08 |
%> |
09 |
<%= str%> |
10 |
</ p > |
1 |
$.mobile.changePage('http://localhost:8082/filing/toAddStep1.htm?disId='+$(this).val()+'&&disName='+str+'', {transition:"none", showLoadMsg:true}); |
這裏用的是jquery mobile中的頁面切換
方法三:用html5本地緩存localStorage傳遞參數
擴展:
針對jquery mobile中切換頁面js不執行的問題:
解決辦法一:把js寫在data-role="page"頁面之內
<div data-role="page" data-title="" data-theme="b" id="home">
...........................
<script>
js代碼
</script>
</div>
解決辦法二:在切換頁面的<a href="" data-ajax="false">設置屬性data-ajax="false"
解決辦法三:把js單獨加載:
$.getScript("js/test.js");