<%@ page language="java" contentType="text/html; charset=gb2312"%>
<html>
<head>
<title>
登录界面
</title>
</head>
<body>
<form action="three92.jsp" method="post">
账号<input name="accout" type="text"><br>
密码 <input name="password" type="password"><br>;
<input type="submit" value="登录">
<%String acc=request.getParameter("accout");
String pass=request.getParameter("password"); %>
<% boolean flag=false;
if(acc.equals(pass))
{flag=true;}
if(flag)
{request.getRequestDispatcher("index1.jsp").forward(request,response);}
else{out.print("账号和密码不同");}
%>
</form>
</body>
</html>
<html>
<head>
<title>
登录界面
</title>
</head>
<body>
<form action="three92.jsp" method="post">
账号<input name="accout" type="text"><br>
密码 <input name="password" type="password"><br>;
<input type="submit" value="登录">
<%String acc=request.getParameter("accout");
String pass=request.getParameter("password"); %>
<% boolean flag=false;
if(acc.equals(pass))
{flag=true;}
if(flag)
{request.getRequestDispatcher("index1.jsp").forward(request,response);}
else{out.print("账号和密码不同");}
%>
</form>
</body>
</html>
你可以在登录按钮上绑定一个点击事件: onclick=“xx()” 然后把代码全部放到xx()方法里面。不过,怎样终止表单提交,emmmm,知道我就不是新人了!!
xx方法返回false可以终止表单提交。