我想显示从我的数据库获取的所有订单。我的OrderDate设置为Date类型,另一个设置为String。但我得到一个错误“未知属性OrderDate”。下面是我用来显示数据的JSP代码。
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="booking.Bean.Order"%>
<%@page import="java.util.Vector"%>
<%@page import="booking.Wrapper.Wrapper"%>
<%@page import="booking.DB.OrderDB"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link href="css/displaytag.css" rel="stylesheet" type="text/css">
<link href="css/alternative.css" rel="stylesheet" type="text/css">
<title>All Order Details</title>
</head>
<body>
<div id="container">
<div id="header">
<jsp:include page="header.jsp" />
</div>
<div id="menu">
<ul>
<li class="menuitem"><a href="aboutC.jsp">About</a>
</li>
<li class="menuitem"><a href="clientsC.jsp">Menu</a>
</li>
<li class="menuitem"><a href="contactC.jsp">Contact Us</a>
</li>
<li class="menuitem"><a href="login.jsp">Logout</a>
</li>
</ul>
</div>
<div id="leftmenu">
<div id="leftmenu_top"></div>
<div id="leftmenu_main">
<jsp:include page="orderMenu.jsp" />
</div>
<div id="leftmenu_bottom"></div>
</div>
<div id="content">
<div id="content_top"></div>
<div id="content_main">
<h2>All Order Details</h2>
<%
OrderDB orderDB = new OrderDB();
Wrapper myWrapper = new Wrapper();
Vector<Order> viewAllOrders = myWrapper.viewAllOrders();
//SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
if (viewAllOrders.size() !=0)
{
request.setAttribute("disOrder", viewAllOrders);
%>
<display:table name="disOrder" export="true" pagesize="10" class="Mars" >
<display:column sortable="true" property="orderId" title="Order ID" />
<display:column sortable="true" property="custId" title="Customer ID" />
<display:column sortable="true" property="OrderDate" format="{0,date,yyyy-MM-dd}" title="Order Date" />
<display:column sortable="true" property="OrderTime" title="Order Time" />
<display:column sortable="true" property="OrderSeat" title="Order Seat" />
<display:column sortable="true" property="BStatus" title="Order Status" />
<display:column sortable="true" property="OCustName" title="Customer Name" />
<display:column sortable="true" property="cOEmail" title="Email" />
<display:column sortable="true" property="cOPhoneNo" title="Contact No"/>
<display:column sortable="true" property="defaulter" title="Defaulter" />
</display:table>
<%
}
else
{
out.print("<h4>No data found!</h4>");
}
%>
</div>
<div id="content_bottom"></div>
<jsp:include page="footer.jsp"/>
</div>
</div>
</body>
</html>
以下是系统获取的异常。
Nov 21, 2012 9:22:57 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Table_Booking] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception: [.LookupUtil] Error looking up property "OrderDate" in object type "booking.Bean.Order". Cause: Unknown property 'OrderDate'] with root cause
java.lang.NoSuchMethodException: Unknown property 'OrderDate'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1122)
at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:408)
at org.displaytag.util.LookupUtil.getProperty(LookupUtil.java:271)
at org.displaytag.util.LookupUtil.getBeanProperty(LookupUtil.java:129)
at org.displaytag.model.Column.getValue(Column.java:124)
at org.displaytag.model.Column.createChoppedAndLinkedValue(Column.java:201)
at org.displaytag.model.Column.initialize(Column.java:178)
at org.displaytag.render.TableWriterTemplate.writeTableBody(TableWriterTemplate.java:313)
at org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate.java:138)
at org.displaytag.render.HtmlTableWriter.writeTable(HtmlTableWriter.java:734)
at org.displaytag.tags.TableTag.writeHTMLData(TableTag.java:1647)
at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1300)
at org.apache.jsp.displayOrder_jsp._jspx_meth_display_005ftable_005f0(displayOrder_jsp.java:262)
at org.apache.jsp.displayOrder_jsp._jspService(displayOrder_jsp.java:151)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Nov 21, 2012 9:22:57 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Table_Booking] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception: [.LookupUtil] Error looking up property "OrderDate" in object type "booking.Bean.Order". Cause: Unknown property 'OrderDate'] with root cause
java.lang.NoSuchMethodException: Unknown property 'OrderDate'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1122)
at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:408)
at org.displaytag.util.LookupUtil.getProperty(LookupUtil.java:271)
at org.displaytag.util.LookupUtil.getBeanProperty(LookupUtil.java:129)
at org.displaytag.model.Column.getValue(Column.java:124)
at org.displaytag.model.Column.createChoppedAndLinkedValue(Column.java:201)
at org.displaytag.model.Column.initialize(Column.java:178)
at org.displaytag.render.TableWriterTemplate.writeTableBody(TableWriterTemplate.java:313)
at org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate.java:138)
at org.displaytag.render.HtmlTableWriter.writeTable(HtmlTableWriter.java:734)
at org.displaytag.tags.TableTag.writeHTMLData(TableTag.java:1647)
at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1300)
at org.apache.jsp.displayOrder_jsp._jspx_meth_display_005ftable_005f0(displayOrder_jsp.java:262)
at org.apache.jsp.displayOrder_jsp._jspService(displayOrder_jsp.java:151)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
谁能帮我解决这个问题???谢谢你的帮助。
答案 0 :(得分:2)
将大写更改为小写: O rderDate - &gt; o rderDate,与其他一些字段相同