您现在的位置是:首页 > 电脑技术查询 > web开发

jsp 多个button旋钮提交到同一个Servlet中

编辑:chaxungu时间:2022-10-10 23:24:19分类:web开发

jsp 多个button按钮提交到同一个Servlet中
在jsp页面上有多个button,我希望实现,在同一个servlet程序中对这几个不同的button进行不同的处理并跳转到不同的页面。应该怎样取得不同的button值? servlet jsp button 分享到:
------解决方案--------------------
引用:Quote: 引用:
服了,不晓得你咋个理解成这样的...
<formaction="StuServlet"method="post">
<inputtype="button"name="action1"value="个人信息"onClick="document.getElementById('btnType').value=this.btnType;this.form.submit()">

<inputtype="button"name="action2"value="修改信息"onClick="document.getElementById('btnType').value=this.btnType;this.form.submit()">
<inputtype="button"name="action3"value="查询信息"onClick="document.getElementById('btnType').value=this.btnType;this.form.submit()">
<inputtype="button"name="action4"value="退出系统"onClick="document.getElementById('btnType').value=this.btnType;this.form.submit()">
<inputtype='hidden'id='btnType'name='btnType'/>
</form>
然后服务端:
StringbtnType=(String)req.getAttribute("btnType");
初学者很多东西还在慢慢摸索和学习中多多包涵
还是不行看样子我程序还是有其他的问题需要修改谢谢啦
你引用那一楼改错了点,注意下一楼的修正