当一个页面有两个或两个以上的表单按钮时怎么分别指向提交各个按钮对应的action呢?
这里可以使用js代码来使用onclick指向对应的function,如代码:
<form name="test" method="post"> <input onclick="add()" /> <input onclick="insert()" /> </form>
对应的js代码:
<script> function add(){ document.test.action="/add.action"; document.test.submit(); } function insert(){ document.test.action="/insert.action"; document.test.submit(); } </script>
点击对应的按钮转到对应的action并submit提交,然后执行对应的controller。