javax.el.PropertyNotFoundException: Property 'stuid' not found如何解决?

首先,我们应该明确,当我们在jsp界面"调用某些实体类的属性",他并不是真正调用该类的属性,而是调用了该属性的get set方法,举个例子,如下实体类:

import java.util.Date;
public class Student {
	private int stuId;
	private String stuName;
	private int stuAge;
	private Date stuBtd;
	private int stuSex;
	private String stuTel;
	private int isDelete;
	private String stuSexView;
	public String getStuSexView() {
		return stuSexView;
	}
	public void setStuSexView(String stuSexView) {
		this.stuSexView = stuSexView;
	}
	public Student() {
		// TODO Auto-generated constructor stub
	}

	public Student(int stuId, String stuName, int stuAge, Date stuBtd,
			int stuSex, String stuTel, int isDelete) {
		super();
		this.stuId = stuId;
		this.stuName = stuName;
		this.stuAge = stuAge;
		this.stuBtd = stuBtd;
		this.stuSex = stuSex;
		this.stuTel = stuTel;
		this.isDelete = isDelete;
	}
	public Student(String stuName, int stuAge, Date stuBtd, int stuSex,
			String stuTel, int isDelete) {
		super();
		this.stuName = stuName;
		this.stuAge = stuAge;
		this.stuBtd = stuBtd;
		this.stuSex = stuSex;
		this.stuTel = stuTel;
		this.isDelete = isDelete;
	}
	public int getStuId() {
		return stuId;
	}
	public void setStuId(int stuId) {
		this.stuId = stuId;
	}
	public String getStuName() {
		return stuName;
	}
	public void setStuName(String stuName) {
		this.stuName = stuName;
	}
	public int getStuAge() {
		return stuAge;
	}
	public void setStuAge(int stuAge) {
		this.stuAge = stuAge;
	}
	public Date getStuBtd() {
		return stuBtd;
	}
	public void setStuBtd(Date stuBtd) {
		this.stuBtd = stuBtd;
	}
	public int getStuSex() {
		return stuSex;
	}
	public void setStuSex(int stuSex) {
		this.stuSex = stuSex;
	}

	public String getStuTel() {
		return stuTel;
	}
	public void setStuTel(String stuTel) {
		this.stuTel = stuTel;
	}
	public int getIsDelete() {
		return isDelete;
	}
	public void setIsDelete(int isDelete) {
		this.isDelete = isDelete;
	}
	@Override
	public String toString() {
		return "Student [stuId=" + stuId + ", stuName=" + stuName + ", stuAge="
				+ stuAge + ", stuBtd=" + stuBtd + ", stuSex=" + stuSex
				+ ", stuTel=" + stuTel + ", isDelete=" + isDelete + "]";
	}
}

jsp部分代码:

<c:forEach items="${studentList}" var="student">
    		<tr onmouseover="this.bgColor='gree'" onmouseout="this.bgColor='white'">
			<td>${student.stuId}</td>
			<td>${student.stuName}</td>
			<td>${student.stuAge}</td>
			<td>${student.stuBtd}</td>
			<td>${student.stuSexView}</td>
			<td>${student.stuTel}</td>
			<td><a href="${pageContext.request.contextPath}/StudentFindByIdServlet?id=${student.stuId}">更新</a></td>
			<td><a href="${pageContext.request.contextPath}/StudentDeleteServlet?id=${student.stuId}" onclick="return confirm('您確定要刪除[${student.stuName}]')">刪除</a></td>
    	</c:forEach>

这种异常的产生有2种情况(以上面例子为例):
第一种:javax.el.PropertyNotFoundException: Property ‘stuId’ not found on type com.jinzhi.entity.Student
这种情况下,说明你的student实体类中的get/set方法的名字可能与这里的调用的名字不一样(一般情况均为大小写错误),只要你有良好的写代码习惯,第二个单词首字母大写,这种错误一般不会犯!如图:
在这里插入图片描述
在这里插入图片描述
第二种:javax.el.PropertyNotFoundException: Property ‘stuid’ not found on type java.lang.String
这种情况的出现完全是因为你的粗心大意造成,在foreach中的items属性没有用"${}"将其索要循环的数组括起来,故找不到.如图:在这里插入图片描述
在这里插入图片描述

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值