jsp页面中输入数量:
<input type="text"
name="productItemList[${t.index}].sum" size="8" />
Action中:
private List<ProductItem> productItemList;
ProductItem类中有Long 类型的sum。因为数量是Long类型,页面数量如果输入字符串,则Struts2会提示:Invalid field value for field "productItemList[1].sum". 
怎么样在properties里填写信息覆盖,这个提示太不友好了,提示:迷糊点在properties里不知道怎么写这个sum字段
invalid.fieldvalue.productItemList.sum 和invalid.fieldvalue.sum都不对,求高手指点。

解决方案 »

  1.   

    长整形不能自动转换吗?那看可以换成其它数据类型不?如int ,decimal不换类型的话,试试Struts2的类型转换,自已定义个类型转换拦截器
      

  2.   

    假如你的action是 MyAction,  那么在MyAction.properties中写
    invalid.fieldvalue.productItemList="提示消息"
    就可以了
      

  3.   

    做法是这样的: 
          
             在 Action的同一目录写个 Action.properties 文件
     
    invalid.feldvalue.属性名 = "提示信息"这样即可     
      

  4.   

    唉。。这个属性是个List集合,集合里是一个对象,现在是对象中的一个属性出现
    类型转换错误。
    大家题目看仔细点啊。
      

  5.   

    举个例子
                Action 
                    Integer age ;  
             Action.properties    file
                 invalid.fieldvalue.age = "你输入的年龄格式不对,请重新输入";
    像这样.
                                
      

  6.   

    你这个是普通字段或者普通对象吧。List里对象的字段试过吗
      

  7.   

    addFieldError & addActionError
      

  8.   

    我这里是List集合中的ProductItem对象的sum属性。
      

  9.   

    那就这样 
                          
              invalid.fieldvalue.productItemList[0].sum= 提示信息;        如果你有好多。那只能是 0,1,2,3,写一路过去就行拉_
      

  10.   


    invalid.fieldvalue.productItemList[0].sum=\u7528\u6237\u53F7\u5FC5\u987B\u662F\u6574\u6570
    invalid.fieldvalue.productItemList[1].sum=\u7528\u6237\u53F7\u5FC5\u987B\u662F\u6574\u6570提示:
    •Invalid field value for field "productItemList[1].sum".
     
      

  11.   


    那就是你的不对拉。。 如上图...怎么会没有呢。invalid.fieldvalue.hardwareApplicationVo.detailVoList[0].account = error.这是我实验的..
      

  12.   


    hardwareApplicationVo 是什么。我写的是productItemList[0].sum=error,不行。
      

  13.   

    能不能把你的代码贴上来,后台的,jsp的。
      

  14.   

    jsp 代码有用的就一句: 当然记得加  标签
    <div style="color:red">
    <s:fielderror></s:fielderror>
    </div>Action  里面也简单    public class JbpmHardwareApplicationAction extends ActionSupport{       // 硬件申请
    private HardwareapllicationVo hardwareApplicationVo;    }    public class HardwareapllicationVo implements java.io.Serializable { // 主健标识
    private String id; // 流水号
    private String hardwareapllicationNum; // 申请人
    private UserVo applyer; // 是否存档
    private Integer isRe; // 备注
    private String re; // 详细单
    private List<HardwareapplicationDetailVo> detailVoList;}public class HardwareapplicationDetailVo implements java.io.Serializable { // 主健标识
    private Integer id; // 名称
    private String name; // 数量
    private Integer account; // 用途
    private String use; // 单位
    private String unit;}
    这样是不会有什么问题的呀_
        
      

  15.   

    我是在jsp页面需要输入数量
    <input type="text"
                name="productItemList[${t.index}].sum" size="8" />发下你的jsp页面的输入框怎么写的?
      

  16.   

    我这里Action的属性不是一个对象,而是一个对象集合。所以跟你的这个还是写法不一样的。
      

  17.   

    哎呀。。你叫我怎么和你说呢。         我的那个属性的结构是 Vo.List<Object> Object.properties 只是多了第一个Vo而已.jsp 里面的写法就是
                          Vo.List[0].propertiesName 因为输入框是固定数量.
                    
      

  18.   

    我现在的JSP页面是:<table>
    <tr class="head">
    <td width="100px">
    &nbsp;&nbsp;ID
    </td>
    <td align="center">
    产品名称
    </td>
    <td>
    产品购买形式
    </td>
    <td align="center">
    单价
    </td>
    <td>
    数量
    </td>


    </tr>
    <s:iterator value="productItemList" var="product" status="t">
    <tr>
    <td width="20">
    <input type="hidden"
    name="productItemList[${t.index}].productId"
    value="${product.id}" />
    <input type="checkbox" name="productItemList[${t.index}].check" 
    value="${product.id}"/>
    ${product.id}
    </td>
    <td width="150">
    <input type="hidden"
    name="productItemList[${t.index}].name"
    value="${product.name}" />
    ${product.name}
    </td>
    <td align="center" width="100">
    <select name="productItemList[${t.index}].buyType" id="p${t.index}" 
             onchange="test5(${product.id},p${t.index})">
    <option value="1" selected="selected">
    周期
    </option>
    <option value="0">
    定期
    </option>
    </select>
    </td>
                                       
    <td width="50">
    <input type="hidden" name="productItemList[${t.index}].price" value="${product.price}" width="20"/>${product.price}/月
    </td>
    <td width="10">
    <s:set name="stDiv" value="#product.id"></s:set>
                                                                         
    <div id="tp_${stDiv}" style="display: none">
    <input type="text"
    name="productItemList[${t.index}].sum" size="8" />
    </div>

    </td>
    </tr>
    </s:iterator>
    </table>
    跟你的有出入,不一样的。