jsplogin.html文件:
<%@ page contenttype="text/html;charset=GB2312" language=java%>
<html><head><title>用户登录界面></title></head>
<body><form name=form action=jsploginBean.jsp method=post Onsubmit="return check()">
<table align=center border=1>
<tr><th scope=col colspan=2 bgcolor=pink> 用户登录</th></tr>
<tr><th scope=row>用户名:</th>
<td>
<input type=text name=username ></td>
<tr><th scope=row>密码:</th><td>
<input type=text name=password ></td></tr>
<tr><th scope=row> </th><<td><input type=submit name=submit value=提交>
<input type=reset name=reset value=重置></tr>
</table></form>
</body></html>
<script type="text/javascript">
function check()
{
if(form.username.value=="")
{
alert("请输入用户名!");
form.username.focus();
return false;
}
if(form.password.value=="")
{
alert("请输入密码!");
form.password.focus();
return false;
}
}
</script>
LoginBean.java文件:
package mybean;
public class LoginBean
{
private String username=null;
private String password=null;
public LoginBean()
{}
public void setName(String value)
{
username=value;
}
public void setPass(String value)
{
password=value;
}
public String getName()
{
return username;
}
public String getPass()
{
return password;
}
public int check()
{
if(username.equals("liuzc")&&password.equals("liuzc"))
{
return 1;
}
else
{
return 0;
}
}
}
jsploginBean.jsp文件:
<%@ page contentType="text/html;charset=GB2312" %>
<jsp:useBean id="login" scope="page" class="mybean.LoginBean"/>
<jsp:setProperty name="login" property="*"/>
<%
int Result=login.check();
if(Result==1)
{
%>
<h2>欢迎<%=login.getName() %>进入商城</h2>
<%}
if(Result==0){ %>
<h2>登录失败!点击<a href="javascript:history.back(-1);">这里</a> 重新登录!</h2>
<% } %>
你写的相当有问题了,多看看 标准动态的定义吧。帮你改后的
jsplogin.html文件:
<html><head>
<meta http-equiv=Content-Type content="text/html;charset=gb2312"/>
<title>用户登录界面></title>
<script type="text/javascript">
function check()
{
if(form.username.value=="")
{
alert("请输入用户名!");
form.username.focus();
return false;
}
if(form.password.value=="")
{
alert("请输入密码!");
form.password.focus();
return false;
}
}
</script>
</head>
<body><form name=form action=jsploginBean.jsp method=post onsubmit="return check()">
<table align=center border=1>
<tr><th scope=col colspan=2 bgcolor=pink> 用户登录</th></tr>
<tr><th scope=row>用户名:</th>
<td>
<input type=text name=username ></td>
<tr><th scope=row>密码:</th><td>
<input type=text name=password ></td></tr>
<tr><th scope=row> </th><td><input type=submit name=submit value=提交>
<input type=reset name=reset value=重置></tr>
</table></form>
</body></html>
——————————————————————————————————————
jsploginBean.jsp文件:
package mybean;
public class LoginBean
{
private String name=null;
private String pass=null;
public LoginBean()
{}
public void setName(String value)
{
name=value;
}
public void setPass(String value)
{
pass=value;
}
public String getName()
{
return name;
}
public String getPass()
{
return pass;
}
public int check()
{
if("liuzc".equals(name)&&"liuzc".equals(pass))
{
return 1;
}
else
{
return 0;
}
}
}
——————————————————————————————
jsploginBean.jsp文件:
<%@ page contentType="text/html;charset=GB2312" %>
<jsp:useBean id="login" scope="request" class="mybean.LoginBean"/>
<jsp:setProperty name="login" property="name" param="username"/>
<jsp:setProperty name="login"property="pass" param="password"/>
<%
int Result=login.check();
if(Result==1)
{
%>
<h2>欢迎<%=login.getName() %>进入商城</h2>
<%}
if(Result==0){ %>
<h2>登录失败!点击<a href="javascript:history.back(-1);">这里</a> 重新登录!</h2>
<% } %>