彭老師有一個問題一直困擾著我,找了很久都解決不了問題

bensonhe發表於2004-08-25
我在系統中定義了一個model
package com.benson.weborder.model;

public class Cust extends Model{
private String id;
private String name;
private String address;
private String password;
private String phone;
private String email;
private int state;
private String regDate;
private String memo;
private String roleid;
private int sex;
private String realName;
private String tmp="benson";

public Cust(String p_id,
String p_name,
String p_realname,
String p_address,
String p_password,
String p_phone,
int p_sex,
String p_email,
int p_state,
String p_regDate,
String p_memo){
this.id = p_id;
this.name = p_name;
this.address = p_address;
this.password = p_password;
this.phone = p_phone;
this.sex = p_sex;
this.email = p_email;
this.state = p_state;
this.regDate = p_regDate;
this.memo = p_memo;
this.realName = p_realname;
}

public Cust(){}

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getRegDate() {
return regDate;
}
public void setRegDate(String regDate) {
this.regDate = regDate;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getRoleid() {
return roleid;
}
public void setRoleid(String roleid) {
this.roleid = roleid;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getTmp() {
return tmp;
}
public void setTmp(String tmp) {
this.tmp = tmp;
}

}

我在下面的頁面呼叫:

<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/MultiPagers.tld" prefix="page" %>
<html>
<head>
<title>
show_customer
</title>
</head>
<body bgcolor="ffffff">
<h1>
JBuilder Generated JSP
</h1>
<html:form action="/admin/customer/save_custoemr" method="POST" onsubmit="return confirm('Delete it or not')">
<table align="center" border="1" cellpadding="0" >
<tr>
<th>Name</th><th>RealName</th><th>Address</th><th>Action</th>
</tr>
<logic:iterate id="cust" name="customer" property="list" type="com.benson.weborder.model.Cust">
<tr>
<td>
<html:link action="/admin/customer/view_customer?action=edit" paramId="id" paramName="cust" paramProperty="id">
<bean:write name="cust" property="name"/>
</html:link>
</td>
<td>
<%=cust.getRealName()%>

</td>
<td><bean:write name="cust" property="address"/></td>
<td><html:multibox property="selectedObjectId" value="<%=cust.getId()%>" />
</td>
</tr>
</logic:iterate>
<tr>
<td colspan="4">
<page:pager actionForm="customer" count="20" pageUrl="/admin/customer/show_all_customer.do">
<page:prev>上一頁</page:prev>
<page:index/>
<page:next>下一頁</page:next>
</page:pager>
</td>
</tr>
</table>
</html:form>
</body>
</html>

但是卻產生了如下的錯誤:
No getter method for property realName of bean cust

經我的測試,知道是struts找不到realName這個欄位,但是其他欄位可以找到,我真的不知道是為什麼,請彭老師幫忙看看,萬分感激!

相關文章