jsp出错:a null object.
jsp出错信息如下:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Attempted a bean operation on a null object.
原码:
<jsp:useBean id="myCar" class="com.wrox.cars.CarBean" />
i have a <jsp:getProperty name="mycar" property="make" /> <br />
my car cost $<jsp:getProperty name="mycar" property="price" />
javaBean源码:
package com.wrox.cars;
import java.io.Serializable;
public class CarBean implements Serializable {
public CarBean() {
}
private String make = "ford";
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
private double cost = 1000.00;
private double taxRate = 17.5;
public double getPrice() {
double price = (cost + (cost * (taxRate/100)));
return price;
}
private void setPrice(double newPrice) {
}
}