1.在按钮上添加onclick时间,并传递参数给js函数,参数可以为input中输入的值,也可以为jsp中获取的值。
οnclick="searchInfo(form1.workername)"
在js函数里调用时要加.value
οnclick="alterInfo(<%=work1.getCode()%>,<%=work1.getName()%>,<%=work1.getDetail()%>,<%=work1.getCount()%>)"
2.然后调用js中的函数实现跳转
function insert(){
window.location.href("workinsert.jsp");
}
function alterInfo(code,name,detail,count){
var string1 = code;
var string2 = name;
var string3 = detail;
var number = count;
window.location.href("alterInfo.jsp?code="+string1+"&name="+string2+"&detail="+string3+"&count="+number);
}
3.然后在跳转到的页面中使用request.getParameter()来获取参数
<%
String code = request.getParameter("code");
String name = request.getParameter("name");
String detail = request.getParameter("detail");
int count = Integer.parseInt(request.getParameter("count"));
%>