struts页面的错误no getter method for property
action代码:
private ActionForward display(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO 自动生成方法存根
ArrayList arraylist = new ArrayList();
ArrayList array = new ArrayList();
// stub
String sid = request.getParameter( "sid ");
/*
* 将板块名称单独取出来
*/
op.setSname(form, request, sid);
HttpSession session = request.getSession();
arraylist = lr
.executeQuery( "select t.TNumber,s.SName,u.UName,t.TTopic,t.TTime,t.TClickCount,t.TId from bbstopic as t inner join bbssection as s on t.TSid = s.SId inner join bbsuser as u on t.TUid = u.UId where t.TSid= "
+ sid);
for (int j = 0; j < arraylist.size(); j++) {
// 在此每个array都表示一条纪录
array = (ArrayList) arraylist.get(j);
tf = new TopicForm();
for (int i = 0; i < array.size(); i++) {
tf.setTnumber(array.get(0).toString());
tf.setTsname(array.get(1).toString());
tf.setTuname(array.get(2).toString());
tf.setTtopic(array.get(3).toString());
tf.setTtime(array.get(4).toString());
tf.setTclickcount(array.get(5).toString());
tf.setTid(array.get(6).toString());
System.out.println(array.get(i));
}
array.add(tf);
}
if (array != null) {
session.setAttribute( "topics ",array);
return mapping.findForward( "showtopic ");
} else {
/*
* 如果查询的板块没有帖子
*/
return mapping.findForward( "fail ");
}
}
页面代码:
<logic:present name= "topics " scope= "session ">
<logic:iterate id= "topic " name= "topics ">
<tr>
<td> <bean:write property= "tnumber " name= "topic "/> </td>
<td> <a href= "/BBS/topic.do?method=lookup&tnumber= <bean:write property= "tnumber " name= "topic "/> &tid= <bean:write property= "tid " name= "topic "/> "> <bean:write property= "ttopic " name= "topic "/> </a> </td>
<td> <bean:write property= "tuname " name= "topic "/> </td>
<td> <bean:write property= "ttime " name= "topic "/> </td>
<td> <bean:write property= "tclickcount " name= "topic "/> </td>
</tr>
</logic:iterate>
</logic:present>
我在action里面的输出语句可以打印出来,
但在页面里面报的no getter method for peoperty
我看过form里面了没问题!
着个是怎么回事?
[解决办法]
你的form中要有相应的getTnumber()、getTid()、getTtopic、getTuname()、getTtime()、getTclickcount()方法。
[解决办法]
no getter method for property 看报错信息好象是FORM里面没有GET方法
[解决办法]
no getter method for peoperty
很清楚了javabean 里面的get方法没有写完整
[解决办法]
对呀对应的form里
[解决办法]
to : liuhappy4541() ---> form里面没问题
我服了你了LZ,真是睁着眼说瞎话,难道服务器有问题,提示错误信息有错!!!
报错信息 "no getter method for property ",完整的提示信息应该在后面还有一个字段是哪个属性没有getter方法的,这里你省略了.
所以说,你的from里肯定是没有get方法,既然你一直强调你的form有getter方法,那的就跟明确的告诉,你的getter方法不符合规范!!!!!!!所以导致程序认不出,说没有getter方法.
form的属性中,关于setter/getter方法的规范,要求首字母要必须大写:如
testForm {
private int aa = 0;
//符合规范,程序会正确运行,
public void setAa (int i) {
this.aa = i;
}
public int getAa () {
return i;
}
//下面的语法不会有错误,程序也不会报错,但是不符合form的规范,所以到页面输出属性后,就会
//报 "no getter method for aa property "的错误.
public void setAa (int i) {
this.aa = i;
}
public int getAa () {
return i;
}
}
还有什么疑问吗?要是还有,请把你的代码帖出来!!!!!!
[解决办法]
肯定是你程序有问题的,系统不会平白无故给你报个错解闷的
[解决办法]
你有的是hibernate吗?
[解决办法]
数据库里提取的数据怎么能放到Form里面的呢。要把Form和数据持久层的Bean分开呀