日期:2014-05-20  浏览次数:20701 次

关于属性验证的问题
我看了一本叫java完全手册的,按照上面说的写了个属性索引的validation 验证的代码,但是报错:method product 没有 getter方法。为什么? 


class helloform extends validatorform 

  private String[] product = {"aa","bb"}; 
   
  public String getProduct(int index){ 
  return product[index]; 
  } 
  publuc String setProduct(int index,String value){ 
  product[index] = value; 
  } 


----------------------------------在validation.xml------------ 
<formset> 
<form name="login"> 
<field property="aa" indexedListProperty="product" depends="required"> 
<arg position="0" key="prompt.aa"/> 
</field> 
</form> 
</formset> 

------------------------在index.jsp中---- 
<html:form action="/..."> 
<html:text property="product[0]"/> 
</html:form> 


我只把有问题的代码手写下来(可能有点小错,不影响纠错)帮忙看看我哪理解错了啊 


------解决方案--------------------
没这么用过
我感觉应该是
<formset> 
<form name="login"> 
<field property="Product" indexedListProperty="product" depends="required"> 
<arg position="0" key="prompt.aa"/> 
</field> 
</form> 
</formset> 

------解决方案--------------------
Form中定义的是个String数组的原因吧.
没试过这样验证数组,验证字符串应该可以.
把Form中属性改成String试下.