我是 Java Web 应用程序的新手。我一直在使用教程来学习 Java。我在尝试使用 jstl 标签时被卡住了。我有一个包含两个字段的类别表,即“名称”和“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 server 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>