彭老師有一個問題一直困擾著我,找了很久都解決不了問題
我在系統中定義了一個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這個欄位,但是其他欄位可以找到,我真的不知道是為什麼,請彭老師幫忙看看,萬分感激!
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這個欄位,但是其他欄位可以找到,我真的不知道是為什麼,請彭老師幫忙看看,萬分感激!
相關文章
- 請教一個一直以來困擾我的關於DAO模式的問題!!!模式
- 解決了一個困擾我近一年的vim顯示中文亂碼的問題
- 彭老師,急!!!!!!!!!我的jndi連線池有問題.能不能幫一下我啊.
- banq,你好,我有一個急需解決的問題??
- 請教彭老師:開發工具使用的問題
- 彭老師幫看下我自己封裝了個JDBC的通用查詢,更新函式有沒有什麼問題。封裝JDBC函式
- 請教彭老師關於jdbc的問題,謝謝!JDBC
- 高手都進來歇歇~解決一個問題關於SE的問題
- 解決 github 訪問不了的問題Github
- 驢解決不了的問題
- 彭老師請進一個技術以外的問題請談談您的看法
- 困擾Chrome使用者多年的大問題,終於要解決了!Chrome
- 請問老師一個關於命令模式的問題模式
- 我niit老師也搞不定的問題
- MySQL 8.0能徹底解決困擾運維的複製延遲問題!MySql運維
- 一個困擾我三天的問題,請高手指點!(關於SUN實現CachedRowSet 的用法)
- 請問彭老師:Jdon所需類庫
- 請教banq老師一個repository的問題
- banq老師 我想問一個很笨的問題關於#會話#跟蹤#的會話
- J道大哥你好!我有個問題是Eclipse debug的問題希望給我解決下!Eclipse
- 怎麼解決老人養老問題
- 有關Tomcat併發的問題,困擾小弟多日,請高手賜教!Tomcat
- 簡單問題複雜著解決
- 彭老師:您好!請教個在jdonframework中關於查詢list中 KEY的問題???Framework
- 【String註解驅動開發】困擾了我很久的AOP巢狀呼叫終於解決了!巢狀
- 解決「問題」,不要解決問題
- banq老師--jdon框架問題框架
- 披著雨披問個面試問題面試
- 請彭老師進來,切實解決一下我的一個困惑,關於本書
- 問題解決方法有三
- 幽默:程式設計中困難的不是解決問題,而是確定要解決的問題 - Paul程式設計
- 困擾著企業的5個大資料誤解大資料
- 一個lua問題解決過程
- 一個小問題的解決方案
- 解決了一個PC的問題
- bang能看過來嗎,幫我解決一個問題麼
- 專利問題仍在 Linux飽受法律糾紛困擾Linux
- 彭老師:關於SimpleJdonFrameworkTest的執行問題,急!急!急!急!急!急!Framework