<%@ 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>