各位大侠帮忙看看,刚开始学习JacaBean就遇到问题。

寒舍人 2004-03-19 03:58:19
请各位帮忙看看下面的程序咋就不对了,
一:JavaBean文件:
package login;
import java.util.*;
public class logBean
{
private String username;
private String password;
private String email;
private Hashtable errors;
public logBean()
{
username="";
password="";
email="";
errors = new Hashtable();
}
public String getUsername()
{
return username;
}
public String getPassword()
{
return password;
}
public String getEmail()
{
return email;
}
public void setUsername(String usernameStr){
username = usernameStr;
}
public void setPassword(String passwordStr)
{
password = passwordStr;
}
public void setEmail(String emailStr)
{
email = emailStr;
}
public void setErrors(String Key,String msg)
{
errors.put(Key,msg);
}
public boolean validate()
{
boolean allOK=true;
if(username.equals(""))
{
errors.put("username","please inter your name");
username="";
allOK=false;
}
if(password.equals("")||(password.length()>10||password.length()<6))
{
errors.put("password","please enter a valid password of 6-10 charactors");
password = "";
allOK=false;
}
if(email.equals("")||(email.indexOf('@')==-1)||(email.indexOf('.')==-1))
{
errors.put("email","please enter a valid Email address");
email="";
allOK=false;
}
return allOK;
}
public String getErrorMsg(String s)
{
String errorMsg=(String)errors.get(s.trim());
return (errorMsg == null)?"":errorMsg;
}
}
二:用户页面
<%@ page language="java" %>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
BODY {FONT-FAMILY:宋体; FONT-SIZE 9pt}
TH {FONT-SIZE: 9pt}
TD {FONT-SIZE: 9pt}
</style>
</head>
<body bgcolor="#FFFFFF">
<form method=post action="log_cm.jsp">
<table border="0" cellspacing="0" width="323" bgcolor"#F0F8FF"
bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF">
<TR>
<TD colspan=2 align='center'><h4>请你注册:</h4></TD>
</TR>
<TR>
<TD align="left">注册名:</TD>
<TD><INPUT TYPE="text" NAME="username"></TD>
</tr>
<TR>
<TD align="left">口  令:</TD>
<TD><INPUT TYPE="password" NAME="password"></TD>
</tr>

<TR>
<TD align="left">注册名:</TD>
<TD><INPUT TYPE="text" NAME="username"></TD>
</tr>
<TR>
<TD colspan=2 align="center">
<INPUT TYPE="submit" size="4" value="注册">  
<INPUT TYPE="RESET" size="4" value="重来">
</TD>
</tr>
</table>
</form><br>
</center>
</body>
</html>
三;验证页面:(错误就在着发生)
<%@ page language="java" %>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>注册验证</title>
</head>
<body>
<jsp:useBean id="handle" class="login.logBean" scope="request"/>
<jsp:setProperty name="handle" property="*"/>
<%
if(handle.validate()){
%>
<jsp:forward page="success.jsp"/>
<%
}
else{
%>
<jsp:forward page="relog.jsp"/>
<%
}
%>

</body>
</html>
提示错误
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\text\org\apache\jsp\view\log_005fcm_jsp.java:47: cannot resolve symbol
symbol : class logBean
location: package login
login.logBean handle = null;
^
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\text\org\apache\jsp\view\log_005fcm_jsp.java:49: cannot resolve symbol
symbol : class logBean
location: package login
handle = (login.logBean) pageContext.getAttribute("handle", OPE);
^
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\text\org\apache\jsp\view\log_005fcm_jsp.java:51: cannot resolve symbol
symbol : class logBean
location: package login
handle = new login.logBean();
...全文
22 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cwbnig 2004-03-22
是否编译java了?
回复
fxywkj 2004-03-19
<%@ page language="java" %>改成<%@ page language="java" import="login.logBean" %>
不是这里的问题,因为有了<jsp:useBean id="handle" class="login.logBean" scope="request"/>
回复
fxywkj 2004-03-19
没有出错!可是也没有注册成功!估计是你的配置问题!MSN:MIKELWU@HOTMAIL.COM
回复
yanglei031 2004-03-19
对的 bean就是放在WEB-INF\classes下 如果有包的话就要在WEB-INF\classes下

建立和包对应的目录结构
回复
penet 2004-03-19
login文件夹放到应用程序下的WEB-INF\classes下
回复
xunyiren 2004-03-19
<%@ page language="java" %>改成<%@ page language="java" import="login.logBean" %>

另外注意把logBean.class放在login文件夹下,再把login文件夹放到应用程序下的WEB-INF\classes下
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-03-19 03:58
社区公告
暂无公告