RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
JSP如何实现页面传值

这篇文章将为大家详细讲解有关JSP如何实现页面传值,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

创新互联公司是一家专业提供肃宁企业网站建设,专注与网站设计、成都网站设计H5技术、小程序制作等业务。10年已为肃宁众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

这周在调支付宝的接口。期间需要把我方程序处理后的参数(交易金额)按照规定的格式传递给支付宝的接口。因为中途要设计到我方程序对一些数据的处理,所以并不方便直接传值过去。思来想去,决定先把我方的数据提交给webwork的Action进行处理,也就是对数据库进行操作;然后把交易金额以及支付宝接口需要的其他参数一并传递给一个JSP页面,并让这个JSP页面在把action直接指向支付宝的网关接口,注意:中间过程中这个JSP页面时不显示出来的。为此,做了如下测试:建立两个JSP页面传值,tes1.jsp和test2.jsp。代码如下:

  1. <%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%> 

  2. <%  

  3. Stringpath=request.getContextPath();  

  4. StringbasePath=request.getScheme()+"://"+request.getServerName()
    +":"+request.getServerPort()+path+"/";  

  5. %> 

  6. > 

  7.  

  8.  

  9. <basehrefbasehref="<%=basepath%>"> 

  10.  

  11. </strong>MyJSP'test1.jsp'startingpage<strong>title></strong> </p></li><li><p><strong><</strong>metahttp-equiv<strong>metahttp-equiv</strong>="pragma"content="no-cache"<strong>></strong> </p></li><li><p><strong><</strong>metahttp-equiv<strong>metahttp-equiv</strong>="cache-control"content="no-cache"<strong>></strong> </p></li><li><p><strong><</strong>metahttp-equiv<strong>metahttp-equiv</strong>="expires"content="0"<strong>></strong> </p></li><li><p><strong><</strong>metahttp-equiv<strong>metahttp-equiv</strong>="keywords"content="keyword1,keyword2,keyword3"<strong>></strong> </p></li><li><p><strong><</strong>metahttp-equiv<strong>metahttp-equiv</strong>="description"content="Thisismypage"<strong>></strong> </p></li><li><p><strong><</strong>metahttp_equiv<strong>metahttp_equiv</strong>="refresh"content="5"<strong>></strong> </p></li><li><p> </p></li><li><p><strong><</strong>scriptlanguage<strong>scriptlanguage</strong>="javascript"type="text/javascript"<strong>></strong> </p></li><li><p>functionexecute(){  </p></li><li><p>varobj=document.getElementById("name");  </p></li><li><p>document.form1.action="alipay/test2.jsp?param="+obj.value;  </p></li><li><p>document.form1.submit();  </p></li><li><p>}  </p></li><li><p><strong>script></strong> </p></li><li><p><strong>head></strong> </p></li><li><p><strong><</strong>bodyonload<strong>bodyonload</strong>="execute();"<strong>></strong> </p></li><li><p><strong><</strong>formname<strong>formname</strong>="form1"method="post"<strong>></strong> </p></li><li><p><strong><table></strong> </p></li><li><p><strong><tr></strong> </p></li><li><p><strong><td></strong> </p></li><li><p>测试JSP页面传值<strong><</strong>inputtype<strong>inputtype</strong>="text"id="username"value="luodada"<strong>></strong> </p></li><li><p><strong>td></strong> </p></li><li><p><strong>tr></strong> </p></li><li><p><strong>table></strong> </p></li><li><p><strong>form></strong> </p></li><li><p><strong>body></strong> </p></li><li><p><strong>html></strong> </p></li></ol></pre><p>tset2.jsp的代码如下:</p><pre><%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%> <%  Stringpath=request.getContextPath();  StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  %> > <html> <head> <basehrefbasehref=""> <title>MyJSP'test2.jsp'startingpagetitle> <metahttp-equivmetahttp-equiv="pragma"content="no-cache"> <metahttp-equivmetahttp-equiv="cache-control"content="no-cache"> <metahttp-equivmetahttp-equiv="expires"content="0"> <metahttp-equivmetahttp-equiv="keywords"content="keyword1,keyword2,keyword3"> <metahttp-equivmetahttp-equiv="description"content="Thisismypage">  head> <body> <%  Stringvalue=request.getParameter("param");  out.print("从test1.jsp传递过来的值是"+value);  %> body> html></pre><p>具体思路如下:</p><p>在JSP页面传值test1.jsp中,通过JavaScript把文本框中的值获取出来,,使test1.jsp在加载进来的时候马上执行页面跳转;</p><p>在JSP页面传值test2.jsp中通过request.getParameter("参数名称");来获取test1.jsp传递过来的值即可。</p><p>关于“JSP如何实现页面传值”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。</p> <br> 网站标题:JSP如何实现页面传值 <br> 文章路径:<a href="http://scyingshan.cn/article/gccdic.html">http://scyingshan.cn/article/gccdic.html</a> </div> <div class="hot_new"> <div class="page_title clearfix"> <h3>其他资讯</h3> </div> <div class="news_list clearfix"> <ul> <li> <a href="/article/degeioc.html">转置函数c语言是什么 转置函数c语言是什么意思啊</a> </li><li> <a href="/article/degeehh.html">路由器交换机命令 路由器交换机命令错误</a> </li><li> <a href="/article/degeicc.html">减法的c语言函数 c语言减法程序源代码</a> </li><li> <a href="/article/degeioj.html">校验密码c语言函数 c语言验证码代码</a> </li><li> <a href="/article/degeidd.html">linux改网段命令 linux怎么修改网卡地址</a> </li> </ul> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <!-- 底部信息 --> <div class="footer wow fadeInUp"> <div class="rowFluid"> <div class="span12"> <div class="container"> <div class="footer_content"> <div class="span4 col-xm-12"> <div class="footer_list"> <div class="span6"> <div class="bottom_logo"><img src="/Public/Home/images/ewm.jpg" alt="微信服务号二维码" /></div> </div> <div class="span6 col-xm-12"> <div class="quick_navigation"> <div class="quick_navigation_title">快速导航</div> <ul> <li><a href="http://seo.cdkjz.cn/mobile/" title="手机网站建设" target="_blank">手机网站建设</a></li><li><a href="http://www.4006tel.net/vision/" title="UI设计" target="_blank">UI设计</a></li><li><a href="http://www.njjbc.cn/" title="南京护栏钻孔机" target="_blank">南京护栏钻孔机</a></li><li><a href="http://www.cdxwcx.cn/tuoguan/meishan.html" title="眉山主机托管" target="_blank">眉山主机托管</a></li><li><a href="https://www.cdxwcx.com/city/jianyang/" title="简阳做网站" target="_blank">简阳做网站</a></li><li><a href="http://www.myzitong.cn/" title="绵阳梓潼网站建设" target="_blank">绵阳梓潼网站建设</a></li><li><a href="http://www.bzwzjz.com/serve/" title="高端网站设计" target="_blank">高端网站设计</a></li> </ul> </div> </div> </div> </div> <div class="span4 col-xm-6 col-xs-12"> <div class="footer_list"> <div class="footer_link"> <div class="footer_link_title">友情链接</div> <ul id="frientLinks"> <a href="https://www.cdcxhl.com/" title="网站制作" target="_blank">网站制作</a> <a href="https://www.cdcxhl.com/" title="网站建设" target="_blank">网站建设</a> <a href="https://www.cdxwcx.com/tuiguang/" title="成都网络推广" target="_blank">网络推广</a> <a href="http://seo.cdkjz.cn/" title="成都网站推广" target="_blank">网站推广</a> <a href="https://www.cdcxhl.com/xiaochengx.html" title="成都微信小程序开发" target="_blank">小程序开发</a> <a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a> </ul> <div class="footer_link_title">网站建设</div> <ul id="frientLinks"> <li><a href="/">营山大橙子建站</a></li> <li><a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a></li> </ul> </div> </div> </div> <div class="span4 col-xm-6 col-xs-12"> <div class="footer_list"> <div class="footer_cotact"> <div class="footer_cotact_title">联系方式</div> <ul> <li><span class="footer_cotact_type">企业:</span><span class="footer_cotact_content">青羊区大橙子信息咨询工作室</span></li> <li><span class="footer_cotact_type">地址:</span><span class="footer_cotact_content">成都市青羊区太升南路288号</span></li> <li><span class="footer_cotact_type">电话:</span><span class="footer_cotact_content"><a href="tel:18980820575" class="call">18980820575</a></span></li> <li><span class="footer_cotact_type">网址:</span><span class="footer_cotact_content"><a href="/" title="营山网站建设">www.scyingshan.cn</a></span></li> </ul> </div> </div> </div> </div> </div> <div class="copyright"> <p>公司名称:青羊区大橙子信息咨询工作室 联系电话:18980820575</p> <p><a href="http://beian.miit.gov.cn" target="_blank" rel="nofollow">网站备案号:蜀ICP备2022028542号-24</a></p> <p>营山大橙子建站 营山网站建设 营山网站设计 营山网站制作 <a href="http://www.cdxwcx.cn/" target="_blank">成都做网站</a></p> </div> </div> </div> </div> </body> </html> <script> $(".technical_support_box_z_info_box img").each(function(){ var src = $(this).attr("src"); //获取图片地址 var str=new RegExp("http"); var result=str.test(src); if(result==false){ var url = "https://www.cdcxhl.com"+src; //绝对路径 $(this).attr("src",url); } }); window.onload=function(){ document.oncontextmenu=function(){ return false; } } </script>