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都不对,求高手指点。
invalid.fieldvalue.productItemList="提示消息"
就可以了
在 Action的同一目录写个 Action.properties 文件
invalid.feldvalue.属性名 = "提示信息"这样即可
类型转换错误。
大家题目看仔细点啊。
Action
Integer age ;
Action.properties file
invalid.fieldvalue.age = "你输入的年龄格式不对,请重新输入";
像这样.
invalid.fieldvalue.productItemList[0].sum= 提示信息; 如果你有好多。那只能是 0,1,2,3,写一路过去就行拉_
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".
那就是你的不对拉。。 如上图...怎么会没有呢。invalid.fieldvalue.hardwareApplicationVo.detailVoList[0].account = error.这是我实验的..
hardwareApplicationVo 是什么。我写的是productItemList[0].sum=error,不行。
<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;}
这样是不会有什么问题的呀_
<input type="text"
name="productItemList[${t.index}].sum" size="8" />发下你的jsp页面的输入框怎么写的?
Vo.List[0].propertiesName 因为输入框是固定数量.
<tr class="head">
<td width="100px">
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>
跟你的有出入,不一样的。