JSP调用JavaBean时出现这样的问题
这是一个简单的例子,index.jsp中有一个提交表单给本页面,然后调用UserBean设置username和password,再在本页面中显示出来,结果出现下面的问题,试了很多例子都是这样,极度郁闷中,希望高手出来指教。index.jap存放在WebRoot/ javabean存放在WebRoot/WEB-INF/classes/ Tomcat 6.0.14 JDK 1.5.0.14
An error occurred at line: 48 in the jsp file: /index.jsp
UserBean
cannot be resolved to a type
45:
46: <jsp:useBean id="user" class="UserBean" scope="page"/>
47: <jsp:setProperty name="user" property="*"/>
48: 用户名:<jsp:getProperty name="user" property="username"/>
49: 密码: <jsp:getProperty name="user" property="password"/>
50:
51: </body>
UserBean.java代码如下:
public class UserBean {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
index.jsp代码如下:
<%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<table width="320" height="167" border="1" align="center">
<form method="post" action="index.jsp">
<tr>
<td width="139" height="57" align="center">姓名:</td>
<td width="165" align="center"><input type="text" name="username" /> </td>
</tr>
<tr>
<td align="center">密码:</td>
<td align="center"><input type="password" name="password" /> </td>
</tr>
<tr>
<td height="53" align="center"><input type="submit" name="login" value="登陆" /> </td>
<td align="center"><input type="reset" name="reset" value="重置" /> <a href="register.html">注册</a></td>
</tr>
</form>
</table>
<hr>
<jsp:useBean id="user" class="UserBean" scope="page"/>
<jsp:setProperty name="user" property="*"/>
用户名:<jsp:getProperty name="user" property="username"/>
密码: <jsp:getProperty name="user" property="password"/>
</body>
</html>
------解决方案--------------------<jsp:useBea