现在的位置: 首页 > 综合 > 正文

struts中一个form表单实现多个按钮的提交

2013年10月02日 ⁄ 综合 ⁄ 共 749字 ⁄ 字号 评论关闭
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<html>
  <head>
    
    <title>main.jsp</title>
	
	<script type="text/javascript">

                function registor(){
		document.getElementById("login").action="<%=request.getContextPath()%>/existAction.action";
		document.getElementById("login").submit();}
	
		function list(){
		document.getElementById("login").action="<%=request.getContextPath()%>/listAction.action";
		document.getElementById("login").submit();}
			
	</script>
  </head>
  
  <body>
  <center>
  	<h2><font color="red">注册</font></h2>
	<form method="post" name="login" id="login">
		用户名:<input type="text" name="username">
		<input type="button" value="显示数据" onclick="list()">//注意:onclick的方法千万不能喝form表单中定义的name和id重名,否则会报网页上有错
		<input type="button" value="注册" onclick="registor()">
	</form>
    </center>
  </body>
</html>

抱歉!评论已关闭.