找不到getter Property XXX问题解决方法
http://www.diybl.com/ 2008-3-21 网络 点击:
[ 评论 ]
文章搜索:
【点击打包该文章】
// in my JSP
<html:form action="actionA" type="ActionFormA">
<logic:iterate id="element" name="list" type="LabelValueBean">
<html:multibox property="propertyA"><bean:write name="element" property="value"/></html:multibox><bean:write name="element" property="label"/>
</logic:iterate>
// in my ActionFormA
String[] propertyA;

public void setPropertyA(String[] str){
this.propertyA = str;
}

public String[] getPropertyA(){
return this.propertyA ;
}
// in my Action
HibernateBean hb = manager.getHibernateBean(id);
httpServletRequest.setAttribute("ActionFormA", hb);说明:在跳转到JSP页面之前对form中的属性进行预填充,图方便直接将属性相同的持久化对象hb存到request中当ActionFormA用了。
错误在此!增加了ActionForm的propertyA属性但是存到request中的确是没有修改的HibernateBean!
修改后 :
HibernateBean hb = manager.getHibernateBean(id);
ActionFormA aForm = new ActionFormA(hb); //将hb数据复制到aForm中
httpServletRequest.setAttribute("ActionFormA", mForm );
It works!

第一次使用Strut的<html:multibox>标签库时,遇到了一个棘手问题:
org.apache.jasper.JasperException: No getter method available for property XXX for bean under name org.apache.struts.taglib.html.BEAN经过了大半天痛苦的挣扎,才找到了这bug的根源。把我的这个问题写下来,希望对遇到的人有所帮助。- Step One:检查JSP和ActionFormBean中是否有拼写错误。
- Step Two:检查在request中修改了属性名为ActionFormBean的代码,看是否存入了错误的FormBean导致属性不匹配。
// in my JSP
<html:form action="actionA" type="ActionFormA">
<logic:iterate id="element" name="list" type="LabelValueBean">
<html:multibox property="propertyA"><bean:write name="element" property="value"/></html:multibox><bean:write name="element" property="label"/>
</logic:iterate>// in my ActionFormA
String[] propertyA;
public void setPropertyA(String[] str){
this.propertyA = str;
}
public String[] getPropertyA(){
return this.propertyA ;
}// in my Action
HibernateBean hb = manager.getHibernateBean(id);
httpServletRequest.setAttribute("ActionFormA", hb);说明:在跳转到JSP页面之前对form中的属性进行预填充,图方便直接将属性相同的持久化对象hb存到request中当ActionFormA用了。错误在此!增加了ActionForm的propertyA属性但是存到request中的确是没有修改的HibernateBean!
修改后 :
HibernateBean hb = manager.getHibernateBean(id);
ActionFormA aForm = new ActionFormA(hb); //将hb数据复制到aForm中
httpServletRequest.setAttribute("ActionFormA", mForm );
It works!

如果图片或页面不能正常显示请点击这里 站内搜索:
推荐文章 |

public void setPropertyA(String[] str)