org.apache.jasper.JasperException / javax.el.PropertyNotFoundException:

时间:2014-03-11 08:21:56

标签: java jsp glassfish propertynotfoundexception

我是Java Web应用程序的新手。我一直在使用教程来学习Java。我试图使用jstl标签时遇到困难。我有一个包含两个字段的类别表,即“Name”和“id”。我使用的图像文件的类别名称和名称是相同的。这是源代码。当我尝试运行该应用程序时,它显示以下错误:

HTTP Status 500 - Internal Server Error

type Exception report

messageInternal Server Error

description
    The server encountered an internal error that prevented it from fulfilling this request.

exception
    org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'id'.

root cause
    javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'id'.

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.
GlassFish Server Open Source Edition 4.0 

我在WEB-INF文件夹下的lib文件夹中添加了javax.servlet.jsp.jstl-api-1.2.1-javadoc.jar和jstl-impl-1.2.jar文件。但我仍遇到上述问题。任何人都可以帮我解决这个问题。

这是我的index.jsp代码。我已经在glassfish服务器4.0中部署了应用程序

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%-- 
    Document   : index
    Created on : Feb 18, 2014, 1:18:40 PM
    Author     : sabin
--%>

<sql:query var="categories" dataSource="jdbc/affablebean">
    SELECT * FROM category
</sql:query>

<div id="indexLeftColumn">
    <div id="welcomeText">
        <p>[ welcome text ]</p>
        categoryImagePath:${initParam.categoryImagePath}
        productImagePath:${initParam.productImagePath}
    </div>
</div>

<div id="indexRightColumn">
    <c:forEach var="category" items="$(categories.rows}">
        <div class="categoryBox">
            <a href="category?${category.id}">
                <span class="categoryLabelText">${category.name}</span>
                <img src="${initParam.categoryImagePath}${category.name}.jpg" alt="${category.name}">
            </a>
        </div>
    </c:forEach>
</div>

1 个答案:

答案 0 :(得分:1)

你有一个拼写错误:$(而不是$ {。更改此行

<c:forEach var="category" items="$(categories.rows}">

<c:forEach var="category" items="${categories.rows}">