gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 22:18:49 25 4
gpt4 key购买 nike

这是我的 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 Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class 'model.CustomerProperty' does not have the property 'mydate'. root cause

javax.el.PropertyNotFoundException: The class 'model.CustomerProperty' does not have the property 'mydate'. note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.

我尝试删除 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>

最佳答案

注意你的 getter setter -

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>

关于java - JSP无法检测到java模型类中新添加的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30389177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com