我在做struts2校验时发现了下面的错误:
   Invalid field value for field "cloth.clothPrice".
但我的代码是下面:
    <field name="cloth.clothPrice" >
       <field-validator type="regex">
                <param name="expression"><![CDATA[^[0-9]*$]]></param>
                <message>衣服价格必须是数字..</message>
          </field-validator>
    </field>
还有个问题,也是在同一个页面,还没有进行校验的时候下面的路径图片是可以显示出来的,但我输入不符合校验时,按提交,由于校验不正确所以跳回原页面时,图片既然显示不出来了。在页面测试时,发现开<s:property value="cloth.images"/>没有值输出,为什么呢?
<img src="<%=basePath%>view/images/<s:property value="cloth.images"/>"还有这个警告一直跟着我不放:2011-7-6 14:38:16 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn
警告: No configuration found for the specified action: 'manager/addCloth.action' in namespace: '/manager'. Form action defaulting to 'action' attribute's literal value.
请高手出招....

解决方案 »

  1.   

    验证发生的错误信息:
    ognl.MethodFailedException: Method "setClothPrice" failed for object org.whj.entity.Clothor@11a9310 [java.lang.NoSuchMethodException: org.whj.entity.Clothor.setClothPrice([Ljava.lang.String;)]
    我定义的clothPrice的double型的...应该怎么改?
      

  2.   

    我定义的clothPrice的double型的...应该怎么改?要么改成String类型
    要么再新添加一个String类型做中转 将你的double的值转成String 赋给这个新建的String
    页面用这个新的String就行了
      

  3.   

    clothPrice 这个是你现在的double型 属性
    新建一个 String clothPrices 
    你可以在页面返回前 给每个对象设置这个clothPrices 属性 setClothPrices(clothPrice .toString)
    也可以将clothPrices 的get方法 修改为 return clothPrice .toString;