标签:传递方式 blog index doc jsp click title div set
跳转方式: window.location.href
参数传递方式:URL
JSP1代码:
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> <script> function go() { //获取#dia的值 var s = document.getElementById("dia").innerHTML; console.log(s); //实现页面之间的跳转和URL传递参数 window.location.href = "index2.jsp?s="+s; } </script> </head> <body> <div> <p id="dia">pass me</p> <button type="button" onclick="go();">click me</button> </div> </body> </html>
JSP2代码:
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <% //接收URL传递来的参数 String flowid = request.getParameter("s"); %> <html> <head> <title>Title</title> </head> <body> <p>使用wind.location.href跳转成功</p> //将参数显示到页面上 <p>取得值为:<%=flowid%></p> </body> </html>
仅供复习知识点参考
标签:传递方式 blog index doc jsp click title div set
原文地址:http://www.cnblogs.com/diachan/p/6879020.html