页面跳转时参数携带与参数接收的几种方式


1.js中页面跳转

 

[javascript]  view plain  copy
 
  1. location.href = path + "/weixin/jsp/submitNewSuccess.jsp?package_number="+package_number  


参数接收方式:

 

 

[html]  view plain  copy
 
  1. <script type="text/javascript">  
  2.     var package_number = "<%=request.getParameter("package_number")%>";  
  3. </script>  

 

 

2.java代码中页面重定向

 

[java]  view plain  copy
 
  1. request.setAttribute("openid", openid);  
[java]  view plain  copy
 
  1. request.getRequestDispatcher("/weixin/jsp/weixinLogin.jsp").forward(request, response);  

页面中参数接收方式:

 

 

[html]  view plain  copy
 
  1. var openid =  "<%=request.getAttribute("openid")%>";  

把参数在java代码里面放到session里面:

 

 

[java]  view plain  copy
 
  1. request.getSession().setAttribute("openid", openId());  

页面中接收参数的方式:

 

 

[html]  view plain  copy
 
    1. <script type="text/javascript">  
    2.     var openid =  "<%=request.getSession().getAttribute("openid")%>";  
    3. </script>  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM