日期:2014-05-17  浏览次数:20728 次

jsp错误提示
jsp代码
HTML code
<html>
<head>
<title>using jsp:setProperty</title>
</head>
<body>
<table border="1" align="center">
    <tr><th class="title">
        using jsp:setProperty
</table>
<jsp:useBean id="entry" class="bean.SaleEntry"></jsp:useBean>
<jsp:setProperty property="itemID" name="entry" value='<%=request.getParameter("itemID") %>'/>
<jsp:setProperty property="numItems" name="entry" value='<%=request.getParameter("numItems") %>'/>
<jsp:setProperty property="discountcode" name="entry" value='<%=request.getParameter("discountcode") %>'/>
<br/>
<table border="1" align="center">
    <tr class="colored"><th>Item ID</th><th>unit price</th><th>number ordered</th><th>total price</th></tr>
    <tr align="right">
        <td><jsp:getProperty name="entry" property="itemID" /></td>
        <td><jsp:getProperty name="entry" property="itemCost"/></td>
        <td><jsp:getProperty property="numItems" name="entry"/> </td>
        <td><jsp:getProperty property="totalCost" name="entry"/></td>
    </tr>
</table>
</body>
</html>


----------------
bean.SaleEntry的代码:
package bean;

public class SaleEntry {
private String itemID = "unknown";
private double discountcode = 1.0;
private int numItems = 0;

public String getItemID() {
return itemID;
}
public void setItemID(String itemID) {
this.itemID = itemID;
}
public double getDiscountcode() {
return discountcode;
}
public void setDiscountcode(double discountcode) {
this.discountcode = discountcode;
}
public int getNumItems() {
return numItems;
}
public void setNumItems(int numItem) {
this.numItems = numItem;
}

public double getItemCost(){
double cost = 0.0;
if (itemID.equals("a1234"))
cost = 12.99*getDiscountcode();
else
cost = -9999;
return (roundToPennies(cost));
}
private double roundToPennies(double cost) {

return (Math.floor(cost*100)/100.0);
}

public double getTotalCost(){
return(getItemCost()*getNumItems());
}
}
---------------------
错误提示:
HTTP Status 500 - 

--------------------------------------------

type Exception report

message 

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

exception 

org.apache.jasper.JasperException: An exception occurred processing JSP page /SaleEntry.jsp at line 12

9: </table>
10: <jsp:useBean id="entry" class="bean.SaleEntry"></jsp:useBean>
11: <jsp:setProperty property="itemID" name="entry" value='<%=request.getParameter("itemID") %>'/>
12: <jsp:setProperty property="numItems" name="entry" value='<%=request.getParameter("numItems") %>'/>
13: <jsp:setProperty property="discountcode" name="entry" value='<%=requ