Struts2를 기반으로하는 프로젝트를 진행 중입니다. 나는 Centres
이라고 불리는 String [] 타입의 프로퍼티를 가진 AddCentreNestedForm
이라는 POJO를 가지고있다.Remedy for java.lang.NoSuchMethodException : 알 수없는 속성 'Centers'
그래서
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;
}
}
지금 액션 클래스에서, 나는 문 아래와 같이있다 :
java.lang.NoSuchMethodException: Unknown property 'Centres'
'addCentreNestedForm':이 라인에
String[] centres =null;
...
...
centres = BeanUtils.getArrayProperty(addCentreNestedForm, "Centres");
, 그것은 예외를 제공합니다 POJO AddCentreNestedForm의 인스턴스입니다.
는I는 애플리케이션이 행이 실행되면, Centres
값이 예외 인터넷 검색에서 {"Centres","-1"}.
인 디버깅, 그것은 BeanUtils
가 언급 속성 적절한 게터 방법을 찾을 수없는 경우,이 예외가 발생하는 것을 언급 .
getter 메소드 이름이 무엇인지 알려 주시기 바랍니다. 'getCentres()'로 이름을 지정했습니다. 이 문제에 대한 다른 해결책이 있다면 알려주십시오.
'AddCentreNestedForm'의 필드 이름을 소문자'centres'로 변경하십시오. –