我正在为此苦苦挣扎,但我无法弄清楚为什么会发生此错误。
我有一个豆子:
package mybeans;
import java.io.Serializable;
public class FrageAntwortListeBean implements Serializable {
private static final long serialVersionUID = 1L;
private String questions;
public FrageAntwortListeBean() {
this.questions = ""
}
public String toString() {
return questions;
}
public String getQuestions() {
return questions;
}
public void setQuestions(String questions) {
this.questions = questions;
}
}
所以现在我想在 JSP 中使用这个 bean:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<jsp:useBean id="meineFragen" class="mybeans.FrageAntwortListeBean" scope="session" />
<jsp:setProperty name="meineFragen" property="*" />
${meineFragen.questions}
现在它正在触发此错误:javax.el.PropertyNotFoundException: Property 'questions' not found on type mybeans.FrageAntwortListeBean
我完全不知道为什么会发生这种情况,因为我以前从未遇到过这个问题......我做错了什么?我简化了一个字符串属性的例子,通常它看起来更复杂,但即使结构简单,我也会得到这个错误!我究竟做错了什么?
即使我使用 scriptlet,eclipse 当然也会建议我使用 getQuestions() 函数,但是在运行 JSP 时它会显示类似的错误。
<%= meineFragen.getQuestions() %>
如果我通过页面指令导入它并使用以下它正在工作。但是,scriptlet 很丑!
<%! FrageAntwortListeBean x = new FrageAntwortListeBean(); %>
<%= x.getQuestions() %>
我感谢所有帮助!:) 使用 apache tomcat 7,重新部署,清理它,编译所有新东西。使用了新安装。没有机会!