标签:编译错误 java网站开发 propertynotfoundexce
问题提出:package bean;
public class Student {
	
	private Integer id;       //学号
	private String name;      //姓名
	private String password;  //密码
	
	public Integer getID() { return id; }
	public String getName() { return name; }
	public String getPassword() { return password; }
	public void setID(Integer id) { this.id =  id; }
	public void setName(String name) { this.name =  name; }
	public void setPassword(String pwd) { this.password = pwd; }
	
}而Jsp中的调用代码是通过EL实现,也导入了相应的包。如下:<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<jsp:directive.page import="DAO.StudentDAO"/>
<jsp:directive.page import="java.util.List"/>
<%
	List studentList = StudentDAO.listStudents();
	request.setAttribute("studentList", studentList);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'student.jsp' starting page</title>
  </head>
  <body>
    <form action="operateStudent.jsp" method=get>
			<table bgcolor="#CCCCCC" cellspacing=1 cellpadding=5 width=100%>
				<tr bgcolor=#DDDDDD>
					<th>选择</th>
					<th>学号</th>
					<th>姓名</th>
					<th>密码</th>
					<th>操作</th>
				</tr>
				
				<c:forEach items="${studentList}" var="stu">
					<tr bgcolor="#FFFFFF">
						<td><input type="checkbox" name="id" value="${stu.id}" /></td>
						<td>${stu.id}</td>
						<td>${stu.name}</td>
						<td>${stu.password}</td>
						<td>
							<a href="addEmployee.jsp?action=edit&id=${stu.id}">修改</a>
							<a href="addEmployee.jsp?action=del&id=${stu.id}" 
								onclick="return confirm('确定删除?')">删除</a>
						</td>
					</tr>
				</c:forEach>
			</table>
		</form>
  </body>
</html>(1).首先确保循环<c:forEach items="${studentList}" var="stu">,然后调用是${stu.id}、${stu.name};
(2).然后属性命名最好是小写的,当然首字母一定要小写,如empNo;
(3).在数据库中create table student( stuid int,username varchar(20)
 )对应的Student类变量private Integer id; private String name;其中类型需要一致,同时设置get和set方法:
<span style="white-space:pre">	</span>private Integer id;       //学号
	private String name;      //姓名
        public Integer getID() { return id; }
        public String getName() { return name; }
        public void setId(Integer id) { this.id =  id; }
	public void setName(String name) { this.name =  name; }(4).在DAO中数据库增删改查操作中类型要一致,并且对应数据库中的学号stuid和姓名username:而当我修改为public IntegergetId() { return id; }后运行结果如下图所示:
[java] javax.el.PropertyNotFoundException: Property 'id' not found on type bean.Student
标签:编译错误 java网站开发 propertynotfoundexce
原文地址:http://blog.csdn.net/eastmount/article/details/45835481