概述
page1源码:
function newDoc() {
window.location.assign("hellow.html")
}
function quzhi() {
var text1 = document.getElementById("name").value; //取得文本框的值
var text2 = document.getElementById("password").value;
alert(text1);//网页提示框
alert(text2);
var myurl = "Test_01" + "?" + "pname=" + text1 + "&password=" + text2;
window.location.assign(encodeURI(myurl))
}
function quzhi2() {
var text1 = document.getElementById("name").value; //
var text2 = document.getElementById("password").value;
var myurl = "hellow.jsp" + "?" + "pname=" + text1 + "&password="+ text2;
window.location.assign(encodeURI(myurl))
}
page2源码:
Insert title herehellow world!
page3源码:
Insert title hereString strName=request.getParameter("pname");
String strPassword=request.getParameter("password");
%>
欢迎您!
您的密码是:
servlet源码:
package test;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Test_01
*/
@WebServlet("/Test_01")
public class Test_01 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Test_01() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
String strName=request.getParameter("pname");
String strPassword=request.getParameter("password");
System.out.println(strName);
System.out.println(strPassword);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
运行后图片
最后
以上就是魁梧睫毛膏为你收集整理的mysql+点击+传值_js实现点击按钮传值的全部内容,希望文章能够帮你解决mysql+点击+传值_js实现点击按钮传值所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复