实体:

package entity;

import java.io.Serializable;

public class Authors implements Serializable {

    private String AuthFirstName;

    public Authors() {
    }

    public String getAuthFirstName() {
        return AuthFirstName;
    }

    public void setAuthFirstName(String AuthFirstName) {
        this.AuthFirstName = AuthFirstName;
    }

}


Servlet:

 List listAuthors = authDAO.findAuthors();
 request.setAttribute("lista", listAuthors);


JSP:

<c:forEach var="var" items="${lista}">
    <c:out value="${var.AuthFirstName}"/>
</c:forEach>


例外:


  javax.el.PropertyNotFoundException:在类型entity.Authors上找不到属性“ AuthFirstName”


这是怎么引起的,我该如何解决?

最佳答案

它应该以小写字母开头。

<c:out value="${var.authFirstName}" />


此外,将基础属性名称也以小写字母开头也将是不错的选择,尽管它在功能上不会造成损害。

private String authFirstName;


也可以看看:


Javabeans specification
Java naming conventions

09-28 10:39