【发布时间】:2014-09-05 16:50:57
【问题描述】:
基本上问题是我无法在 jsp 页面中获取 java bean 的属性。我正在使用 Java EE7 Recipes 书中的示例。我在 JSP 页面的正文中有下一条语句:
<body>
<jsp:useBean id="dateBean" scope="application" class="business.DateBean" />
<h2>The current date is: ${dateBean.currentDate}</h2>
</body>
NetBeans 提示的错误部分是:
${dateBean.currentDate}
我正在使用的 Java Bean 类如下:
package business;
import java.util.Date;
public class DateBean implements java.io.Serializable {
private Date currentDate = new Date();
public Date getCurrentDate() {
return currentDate;
}
public void setCurrentDate(Date currentDate) {
this.currentDate = currentDate;
}
}//DateBean
每当我尝试运行 JSP 时,我得到的错误如下:
PWC6038: "${dateBean.currentDate}" contains invalid expression(s):
javax.el.ELException: Unable to find ExpressionFactory of type:
org.apache.el.ExpressionFactoryImpl
做了一些研究,我发现下面的标签可能丢失了,所以我添加了(在 JSP 页面中)但仍然无法正常工作。
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
有人知道哪里出了问题吗?非常感谢!!!
完整的jsp文件如下:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
</head>
<body>
<jsp:useBean id="dateBean" scope="application" class="business.DateBean" />
<h2>The current date is: ${dateBean.currentDate}</h2>
</body>
</html>
【问题讨论】:
-
我们可以看看你的整个jsp文件吗?
-
您在 lib 文件夹或 CLASSPATH 中有哪些 jar 文件或依赖项?
-
请在下面找到我在 lib 文件夹 (C:\Java\jdk1.8.0_05\lib) 中的 jar 文件:
javafx.jar dt.jar javafx-mx.jar jconsole.jar mysql-connector-java-5.1.30-bin.jar sa-jdi.jar tools.jar