JSP如何实现页面传值-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

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://kswsj.cn/article/gccdic.html">http://kswsj.cn/article/gccdic.html</a> </div> </div> <div class="other"> <h3>其他资讯</h3> <ul> <li> <a href="/article/jjheic.html">AtomicIntegerArray、AtomicLongArray怎么使用</a> </li><li> <a href="/article/jjheig.html">分布式数据库DDMSidecar模式如何部署负载均衡</a> </li><li> <a href="/article/jjheip.html">函数计算怎样访问MySQL数据库</a> </li><li> <a href="/article/jjhecs.html">什么是htmlmap标签</a> </li><li> <a href="/article/jjhece.html">ios电子书翻页效果代码详解</a> </li> </ul> </div> </div> <div class="line"></div> <!--底部--> <footer id="5"> <div class="foot1 container"> <div class="list"> <div class="item"> <a href="javascript:;"> <span class="ico1"><i class="iconfont"></i><img src="/Public/Home/img/ewm.png" alt=""></span> <strong>关注我们</strong> </a> </div> <div class="item"> <a href="" target="_blank"> <span><i class="iconfont"></i></span> <strong>索要报价</strong> </a> </div> <div class="item"> <a href="" target="_blank"> <span><i class="iconfont"></i></span> <strong>我要咨询</strong> </a> </div> <div class="item"> <a href="" target="_blank"> <span><i class="iconfont"></i></span> <strong>找到我们</strong> </a> </div> <div class="item"> <a href="" target="_blank"> <span><i class="iconfont"></i></span> <strong>投诉建议</strong> </a> </div> </div> <div class="tel"> <dl> <tel><a href="tel:400-028-6601" target="_blank">400-028-6601</a></tel><br> <span>也许您需要专业的服务,欢迎来电咨询</span> </dl> <dl> <tel><a href="tel:18980820575" target="_blank">18980820575</a></tel><br> <span>您的需求,是我们前进的动力</span> </dl> </div> </div> <div class="friend"> <div class="container"> <span class="tit">友情链接:</span> <div class="inner"> <a href="https://www.cdcxhl.com/jigui/" target="_blank">机柜租用</a><a href="https://www.cdcxhl.com/link/" target="_blank">买卖链接</a><a href="https://www.cdcxhl.com/cloud/" target="_blank">成都云服务器</a><a href="https://www.cdcxhl.com/xiangyingshi.html" target="_blank">成都响应式网站设计公司</a><a href="https://www.cdcxhl.com/app.html" target="_blank">app软件开发公司</a><a href="https://www.cdcxhl.com/quanwang.html" target="_blank">全网整合营销推广</a><a href="https://www.cdcxhl.com/ruanwen/" target="_blank">营销软文</a><a href="https://www.cdcxhl.com/ruanwen/" target="_blank">软文推广</a><a href="https://www.cdcxhl.com/weihu/" target="_blank">成都网站维护公司</a><a href="https://www.cdcxhl.com/xiaochengx.html" target="_blank">成都微信小程序开发</a><a href="https://www.cdcxhl.com/tuoguan/" target="_blank">成都服务器托管</a><a href="https://www.cdcxhl.com/xiangyingshi.html" target="_blank">成都响应式网站建设公司</a><a href="https://www.cdcxhl.com/tuoguan/yaan/" target="_blank">川西大数据中心</a><a href="https://www.cdcxhl.com/" target="_blank">网站制作</a><a href="https://www.cdcxhl.com/qiye.html" target="_blank">成都企业网站建设</a><a href="https://www.cdcxhl.com/ruanwen/" target="_blank">软文发稿</a><a href="https://www.cdcxhl.com/zuyong/" target="_blank">服务器租用</a><a href="https://www.cdcxhl.com/" target="_blank">成都网站设计</a> </div> </div> </div> <div class="foot"> <div class="container"> <div class="footNav"> <h3>网站建设</h3> <a href="https://www.cdcxhl.com/mobile.html" target="_blank">移动网站建设</a><a href="http://www.dzzwz.com/" target="_blank">网站建设公司</a><a href="http://www.cxhlcq.com/" target="_blank">重庆网站建设</a> </div> <div class="footNav"> <h3>服务器托管</h3> <a href="https://www.xwcx.net/tgxq/cdghjf.html" target="_blank">成都光华机房</a><a href="http://www.cdxwcx.cn/tuoguan/mianyang.html" target="_blank">绵阳托管服务器</a><a href="https://www.cdcxhl.com/idc/cqhx.html" target="_blank">重庆电信回兴机房托管</a> </div> <div class="footNav"> <h3>网站制作</h3> <a href="http://www.gawzjs.com/" target="_blank">广安网站制作公司</a><a href="https://www.cdcxhl.com/" target="_blank">成都网站制作</a><a href="http://www.cqcxhl.com/" target="_blank">网站制作</a> </div> <div class="footNav"> <h3>企业服务</h3> <a href="https://www.cdcxhl.com/service/zzgj.html" target="_blank">备案资质管家服务</a><a href="https://www.cdcxhl.com/service/shipinxuke.html" target="_blank">食品经营许可证</a><a href="https://www.cdcxhl.com/link/" target="_blank">友情链接出售</a> </div> <div class="fr ecode"> <div class="fl"> <img src="/Public/Home/img/ewm.jpg"> <p>关注企业微信</p> </div> <div class="fr slogan"> <p class="icon"> <a class="ph" href=""><i class="iconfont"></i></a> <a class="qq" href="tencent://message/?uin=1683211881&Site=&Menu=yes"><i class="iconfont"></i></a> </p> <p> <i>想要找 </i> <a href="">小程序开发</a>、<a href="">APP开发</a>、 <a href="">营销型网站建设</a>、<a href="">网站建设</a>、 <i><a href="">网站定制开发</a></i> ,就选<a href="">创新互联</a> </p> </div> </div> </div> <div class="bottom container"> <p class="fl"> 版权所有:成都创新互联科技有限公司 备案号:<a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备19037934号</a> 服务热线:028-86922220 </p> <p class="fr"> <a href="https://www.cdxwcx.com/" target="_blank">成都网站建设</a>: <a href="https://www.cdcxhl.com/" target="_blank">创新互联</a> </p> </div> </div> </footer> <!--在线咨询--> <div class="fot"> <ul> <li> <a href="https://p.qiao.baidu.com/cps/mobileChat?siteId=11284691&userId=6256368&type=1&reqParam=%20{%22from%22:0,%22sessionid%22:%22%22,%22siteId%22:%2211284691%22,%22tid%22:%22-1%22,%22userId%22:%226256368%22,%22ttype%22:1,%22siteConfig%22:%20{%22eid%22:%226256368%22,%22queuing%22:%22%22,%22siteToken%22:%226ce441ff9e2d6bedbdfc2a4138de449e%22,%22userId%22:%226256368%22,%22isGray%22:%22false%22,%22wsUrl%22:%22wss://p.qiao.baidu.com/cps3/websocket%22,%22likeVersion%22:%22generic%22,%22siteId%22:%2211284691%22,%22online%22:%22true%22,%22webRoot%22:%22//p.qiao.baidu.com/cps3/%22,%22bid%22:%22160142915792139572%22,%22isSmallFlow%22:0,%22isPreonline%22:0,%22invited%22:0%20},%22config%22:%20{%22themeColor%22:%224d74fa%22%20}%20}&appId=&referer=&iswechat=0&expectWaiter=-1&openid=null&otherParam=null&telephone=null&speedLogId=null&eid=null&siteToken=6ce441ff9e2d6bedbdfc2a4138de449e" target="_blank"> <img src="/Public/Home/img/fot1.png" alt=""> <p>在线咨询</p> </a> </li> <li> <a href="tel:18980820575" target="_blank"> <img src="/Public/Home/img/fot2.png" alt=""> <p>拨打电话</p> </a> </li> </ul> </div> </body> </html> <script> $(".con 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>