没有getter方法可用于具有名称的bean的属性 [英] No getter method available for property for bean with name
问题描述
我试图用Struts填充选择。但是,我收到以下错误消息:
名称 com.packagename.branchImpl
中的属性标签没有getter方法可用没有变量被调用'label'在它看起来不是它的类中,所以我不知道它是如何寻找的 label
My JSP select:
< html:select name =querySwiftLogFormproperty =分支>
< cain:optionsCollection name =querySwiftLogFormproperty =branchList/>
< / html:select>
struts_config.xml
:
< form-bean name =querySwiftLogFormtype =com.citibank.cain.controller.web。 struts.forms.QuerySwiftLogForm>
< / form-bean>
form class是一个非常典型的实体类
<有关为何发生此错误的任何建议? 请 < html: optionsCollection
。最后一个标记为标签
和值
/ code>属性。如果您在集合bean中有不同的属性名称,那么可以使用标签
和值
来指定标签。例如,如果您有一个集合 List< MyBean>
并且
public类MyBean实现Serializable {
private String key;
私人字符串名称;
// //为
}
获得者和设置者然后呢你应该使用
< html:select name =querySwiftLogFormproperty =branch>
< / html:select>
如果您没有可用于集合的bean,那么您可以使用< a href =http://struts.apache.org/development/1.x/apidocs/org/apache/struts/util/LabelValueBean.html =nofollow> LabelValueBean
。你需要用该bean的实例填充集合。然后 lable
和 value
属性对于该bean不是必需的,因为它将使用默认值。
另外,如果使用映射到动作的表单,那么不需要 name
属性。
I'm trying to populate a select with Struts. However, I'm getting this error message:
No getter method available for property label under name com.packagename.branchImpl
There is no variable called 'label' in the class in which its looking either, so I don't know how it is looking for label
My JSP select:
<html:select name="querySwiftLogForm" property="branch" >
<cain:optionsCollection name="querySwiftLogForm" property="branchList" />
</html:select>
struts_config.xml
:
<form-bean name="querySwiftLogForm" type="com.citibank.cain.controller.web.struts.forms.QuerySwiftLogForm">
</form-bean>
form class is a very typical entity class
any suggestions as to why this error occurs?
It could be a typo with <cain:optionsCollection
should be <html:optionsCollection
. The last tag uses a property
attribute for the collection of beans that have label
and value
properties. If you have a different property names in the collection bean then it could be specified using the label
and value
attributes of the tag. For example if you have a collection List<MyBean>
and
public class MyBean implements Serializable {
private String key;
private String name;
//getters and setters for both
}
then you should use
<html:select name="querySwiftLogForm" property="branch" >
<html:optionsCollection name="querySwiftLogForm" property="branchList" label="name" value="key"/>
</html:select>
If you don't have a bean that you could use with the collection, then you could use LabelValueBean
. And you need to fill the collection with the instances of that bean. Then lable
and value
attributes not necessary for that bean because it will use the defaults.
Also, if you use the form that is mapped to the action then name
attribute is not necessary.
这篇关于没有getter方法可用于具有名称的bean的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!