I am working on a project based on Struts2. I have a POJO called AddCentreNestedForm
which has one of the property of type String[] called Centres
.
So
public class AddCentreNestedForm{
....
....
private String[] Centres = new String[]{"-1","-1","-1","-1","-1","-1"};
...
...
public String[] getCentres(){
return Centres;
}
public void setCentres(String[] Centres){
this.Centres = Centres;
}
}
Now in the action class, i have a statement like below:
String[] centres =null;
...
...
centres = BeanUtils.getArrayProperty(addCentreNestedForm, "Centres");
on this line, it gives exception :
java.lang.NoSuchMethodException: Unknown property 'Centres'
'addCentreNestedForm' is an instance of POJO AddCentreNestedForm.
I debugged the application, when this line is executed, the value of Centres
is {"Centres","-1"}.
On googling this exception, it mentions that this exception occurs when BeanUtils
is not able to find proper getter method for the mentioned property.
Please let me know what should be the getter method name, I have named it as 'getCentres()'. Please let me know if there is any other solution to this problem.