JSP无法检测java模型类中新添加的元素

时间:2015-05-22 05:45:28

标签: java jsp

这是我的java模型类 - CustomerProperty.java

package model;

import java.io.InputStream;

public class CustomerProperty {

public CustomerProperty() {

}

public int propertyid;
public String name;
public String phone;
public String occupation;
public String address1;
public String address2;
public String postcode;
public String city;
public String state;
public String payment;
public InputStream photo;
public String agent;
public String IDproject;
public String[] quickSale;
public String ICnumber;
public String bag;
public String mydate;

public int getPropertyid() {
    return propertyid;
}

public void setPropertyid(int propertyid) {
    this.propertyid = propertyid;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getPhone() {
    return phone;
}

public void setPhone(String phone) {
    this.phone = phone;
}

public String getICnumber() {
    return ICnumber;
}

public void setICnumber(String ICnumber) {
    this.ICnumber = ICnumber;
}

public String getICNUMBER() {
    return ICnumber;
}

public void setICNUMBER(String ICnumber) {
    this.ICnumber = ICnumber;
}

public String getOccupation() {
    return occupation;
}

public void setOccupation(String occupation) {
    this.occupation = occupation;
}

public String getAddress1() {
    return address1;
}

public void setAddress1(String address1) {
    this.address1 = address1;
}

public String getAddress2() {
    return address2;
}

public void setAddress2(String address2) {
    this.address2 = address2;
}

public String getPostcode() {
    return postcode;
}

public void setPostcode(String postcode) {
    this.postcode = postcode;
}

public String getCity() {
    return city;
}

public void setCity(String city) {
    this.city = city;
}

public String getState() {
    return state;
}

public void setState(String dateTime) {
    this.state = dateTime;
}

public String getPayment() {
    return payment;
}

public void setPayment(String payment) {
    this.payment = payment;
}

public InputStream getPhoto() {
    return photo;
}

public void setPhoto(InputStream photo) {
    this.photo = photo;
}

public String getAgent() {
    return agent;
}

public void setAgent(String agent) {
    this.agent = agent;
}

public String getIDproject() {
    return IDproject;
}

public void setIDproject(String IDproject) {
    this.IDproject = IDproject;
}

public String[] getQuickSale() {
    return quickSale;
}

public void setQuickSale(String[] quickSale) {
    this.quickSale = quickSale;
}

public String getMyDate() {
    return mydate;
}

public void setMyDate(String mydate) {
    this.mydate = mydate;
}

每当我的JSP调用这个java类时,它只能检测原始元素。我添加了一个新元素 - mydate,它就像永远无法检测到它。

以下是错误代码。

  

pe异常报告

     

messageInternal Server Error

     

description服务器遇到阻止它的内部错误   完成此请求。

     

例外

     

org.apache.jasper.JasperException:javax.el.PropertyNotFoundException:   班级' model.CustomerProperty'没有财产   '数值指明MyDate&#39 ;.根本原因

     

javax.el.PropertyNotFoundException:类' model.CustomerProperty'   没有财产' mydate'。注意完整的堆栈跟踪   GlassFish Server中提供了异常及其根本原因   开源版4.0日志。

我试图删除java类并再次重新创建,但是,JSP只能检测我的前16个元素而不是任何新添加的元素。

任何解决方案?感谢

下面是我的JSP文件代码。

<head>
    <title>Project Sales Report</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
</head>
<body>

    <p align="center" style="font-family:times;font-size:40pt"><c:out value="${project2.projectName}"/> Sales Report</p>
    <table align="center" bgcolor="silver" border="1" cellspacing="0" cellpadding="20" class="customer" >
        <thead>
            <tr>             
                <th>Unit ID</th>
                <th>Agent</th>
                <th>Customer Name</th>
                <th>IC Number</th>
                <th>Phone Number</th>
                <th>Occupation</th>
                <th>Address 1</th>
                <th>Address 2</th>
                <th>Postcode</th>
                <th>City</th>
                <th>State</th>
                <th>Payment Type</th>
                <th>Receipt</th>
            </tr>
        </thead>
        <tbody>
            <c:forEach items="${customerdetail}" var="abc">
                <tr>
                    <td><c:out value="${abc.propertyid}"/></td>
                    <td><c:out value="${abc.agent}" /></td>
                    <td><c:out value="${abc.name}" /></td>
                    <td><c:out value="${abc.ICnumber}" /></td>
                    <td><c:out value="${abc.phone}" /></td>
                    <td><c:out value="${abc.occupation}" /></td>
                    <td><c:out value="${abc.address1}" /></td>
                    <td><c:out value="${abc.address2}" /></td>
                    <td><c:out value="${abc.postcode}" /></td>
                    <td><c:out value="${abc.city}" /></td>
                    <td><c:out value="${abc.mydate}" /></td>
                    <td><c:out value="${abc.payment}" /></td>
                </tr> 
            </c:forEach>
        </tbody>
    </table> 
    <p>&nbsp;</p>
    <div align="center">
        <button type="button" style="width:70px;">Print</button>
        <input type="button" value="Back" onClick="history.go(-1);
                return true;" style="width:70px;"/>
    </div>

</body>

1 个答案:

答案 0 :(得分:3)

注意你的getter setters -

public String mybag() {
    return mydate;
}

public void setmybag(String mydate) {
    this.mydate = mydate;
}

应该是setMydategetMydate。不是吗?

更新 -

案例敏感。

public String mydate; 

这应该是

public String myDate;

您的JSP应该是abc.myDate而不是abc.mydate

<td><c:out value="${abc.mydate}" /></td>