如何在servlet中获取JSP表单中submit的值
在JSP页面中有两个SUBMIT~!
<form method= "post " action= "servlet2 ">
<br> <br>
<p> <input type= "text " name= "name "/>
<p> <input type= "password " name= "pwd "/>
<p> <input type= "submit " name= "注册 " value= "zhu "/>
<input type= "submit " name= "登录 " value= "deng ">
<input type= "reset " name= "取消 " value= "Reset ">
如何获取两个不一样的值在servlet中进行操作~!
请各位大虾指教~!
------解决方案--------------------一个form只能有一个submit 可以放在两个form里或是用按钮button提交
------解决方案--------------------String name = request.getParameter( "name ");
String pwd = request.getParameter( "pwd ");
------解决方案--------------------对,只能有一个SUBMIT的
建议你用BUTTON吧,再用JS控制即可
------解决方案--------------------用BUTTON 在里面设置 一个onclick触发 转向到你的注册页面
------解决方案-------------------- <input type= "button " value= "注册 " onclick= "this.form.optype.value= '注册 ';this.form.submit() " />
<input type= "button " value= "登录 " onclick= "this.form.optype.value= '登录 ';this.form.submit() " />
<input type= "button " value= "取消 " onclick= "this.form.optype.value= '取消 ';this.form.submit() " />
------解决方案-------------------- <form method= "post " action= "servlet2 ">
<br> <br>
<p> <input type= "text " name= "name "/>
<p> <input type= "password " name= "pwd "/>
<input type= "hidden " name= "h "/>
<p> <input type= "submit " name= "注册 " value= "zhu " onclick= "h.value=this.value "/>
<input type= "submit " name= "登录 " value= "deng " onclick= "h.value=this.value ">
<input type= "reset " name= "取消 " value= "Reset ">
在Servlet根据hidden的判断
------解决方案--------------------ls的看着不错ding
------解决方案--------------------document.forms[0].submit()
也可以用脚本写
------解决方案--------------------session最为简单..
在jsp中session.setAttribute( " ");
在servlet中session.getAttribute( " ");