Весенний массив со строками - PullRequest
0 голосов
/ 28 ноября 2011

Я работаю с некоторой Java, которую я генерирую с JAXB, но я не думаю, что JAXB является проблемой, так как структура сгенерированного кода соответствует методам getter и setter для свойств Spring, которые теперь работают, но ранее дали мнеисключение такого же типа.

Причина: org.springframework.beans.NotWritablePropertyException: недопустимое свойство 'previousCurrentEstateNo' класса бина [ca.qc.ic.osb.efilingClasses.EIS]: свойство бина 'previousCurrentEstateNo'недоступен для записи или имеет недопустимый метод установки.Соответствует ли тип параметра установщика типу возвращаемого значения получателя?

Разница здесь заключается в использовании массива String.Я пробовал различные предложения, которые должны работать без успеха.Я использую Spring 3.0.6.

<bean id="eisJointSummary" class="ca.qc.ic.osb.efilingClasses.EIS"    
          scope="prototype" lazy-init="true">
    <property name="previousCurrentEstateNo" >
       <list>
     <value>1234</value>
        </list>
     </property>   
 </bean>

в классе EIS:

 public static class Estate

{

    protected String[] previousCurrentEstateNo;



  public String[] getPreviousCurrentEstateNo() {
        if (this.previousCurrentEstateNo == null) {
            return new String[ 0 ] ;
        }
        String[] retVal = new String[this.previousCurrentEstateNo.length] ;
        System.arraycopy(this.previousCurrentEstateNo, 0, retVal, 0, this.previousCurrentEstateNo.length);
        return (retVal);
    }


    public String getPreviousCurrentEstateNo(int idx) {
        if (this.previousCurrentEstateNo == null) {
            throw new IndexOutOfBoundsException();
        }
        return this.previousCurrentEstateNo[idx];
    }

    public int getPreviousCurrentEstateNoLength() {
        if (this.previousCurrentEstateNo == null) {
            return  0;
        }
        return this.previousCurrentEstateNo.length;
    }


    public void setPreviousCurrentEstateNo(String[] values) {
        int len = values.length;
        this.previousCurrentEstateNo = ((String[]) new String[len] );
        for (int i = 0; (i<len); i ++) {
            this.previousCurrentEstateNo[i] = values[i];
        }
    }


    public String setPreviousCurrentEstateNo(int idx, String value) {
        return this.previousCurrentEstateNo[idx] = value;
    }

Спасибо

1 Ответ

0 голосов
/ 28 ноября 2011

Вы создаете компонент типа ca.qc.ic.osb.efilingClasses.EIS, и у этого класса нет свойства previousCurrentEstateNo.

Из того, что я могу судить по предоставленной вами информации, previousCurrentEstateNo является свойством Estate.

Я предполагаю, что EIS имеет свойство типа Estate?

Попробуйте что-нибудь на этот счет:

<bean id="eisJointSummary" class="ca.qc.ic.osb.efilingClasses.EIS"    
      scope="prototype" lazy-init="true">

    <property name="nameOfTheEstatePropertyInEIS">
        <bean class="ca.qc.ic.osb.efilingClasses.EIS.Estate">
            <property name="previousCurrentEstateNo">
                <list>
                    <value>1234</value>
                </list>
            </property>
        </bean>
    </property>
</bean>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...