1.button的type设置为button 而不用submit,并添加onclick方法调用js函数
<input type="button" name="confirmAlter" value="确认修改" οnclick="changeInfo(form1.code,form1.name,form1.detail,form1.count)"/>
2.传到js函数中,然后提交表单到servlet并传递参数
<script language="javascript"> function changeInfo(code,name,detail,count){ var string1 = code.value; var string2 = name.value; var string3 = detail.value; var number = count.value; //alert("hello word!");
document.getElementById('form1').action="workServlet?action=alterInfo&code="+string1+"&name="+string2+"&detail="+string3+"&count="+number; document.getElementById("form1").submit(); } </script>
3.在servlet中调用request.getParameter()方法即可获取参数