实在鳖不住了,不得不发,搞这个问题已经快出离愤怒了,求各位神仙下凡给小弟解释一下

07-04-19 diamondsong

在jsp需要将动态属性通过nested迭代出来,页面赋值后提交到action并保存

操作步骤

1.一个属性是个vo

属性list中装多个vo

2.属性list赋给actionForm.prptyList(List lst)

3.在页面通过nested迭代出actionForm.prptyList中的vo,展示在页面中(显示没问题)

4.form.submit()后抛如下异常

StandardWrapperValve[action]: Servlet.service() for servlet action threw exception

java.lang.IndexOutOfBoundsException: Index: 5, Size: 0

at java.util.ArrayList.RangeCheck(ArrayList.java:507)

at java.util.ArrayList.get(ArrayList.java:324)

at org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:433)

at org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:340)

at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:684)

at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715)

at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:884)

at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)

at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)

at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)

at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)

at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)

at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)

at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)

at com.spsoft.framework.filters.SaveRequestFilter.doFilter(SaveRequestFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)

at com.spsoft.framework.filters.SecurityFilter.doFilter(SecurityFilter.java:140)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)

at com.spsoft.framework.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:39)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)

ActionForm代码如下:

private static final long serialVersionUID = 1L;

private Long accsetId;

private Long datasetverId;

private Long prjitemId;

private Long subacctmplId;

private Long prjassId;

private Long prjestiitemId;

private Long estcolId;

private String assname;

private Long asstypeId;

private String assmod;

private String structure;

private String metrunit;

private Long number;

private String location;

private BigDecimal assworth=new BigDecimal(0);

private String assworthStr;

private String prjassStatus;

private String flag;

private List selectPrjassCol=new ArrayList(); //属性list

Action代码如下:

jsp代码:

diamondsong
2007-04-19 17:15

action 代码

public ActionForward showAddNewPrjAss(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response)

{

PrjAssActionForm form = (PrjAssActionForm) actionForm;

String prjItemId = (String) request.getParameter("prjItemId");

//String prjEstIItemId = (String) request.getParameter("prjEstIItemId");

//String estcolId = (String) request.getParameter("estcolId");

Long subacctmplId = Long.valueOf(request.getParameter("subAccTmplId"));

form.setPrjitemId(new Long(prjItemId));

form.setPrjestiitemId(null);

form.setEstcolId(null);

form.setSubacctmplId(subacctmplId);

// 得到当前资产台帐模板的属性列表

List prptyList = Services.getProjectModuleServices().getPrjSubAccTmplService().getPrjAssTmplPrpty(PrjUtil.getAccSetId(), PrjUtil.getDataSetVersionId(),subacctmplId);

PrjUtil.debug("prptyList.size=" + prptyList.size());

List selectPrjassCol = new ArrayList();

for (int i = 0; i < prptyList.size(); i++)

{

PrjSubItemVO item = (PrjSubItemVO) prptyList.get(i);

CommonUseVO commonvo = new CommonUseVO();

commonvo.setPrjassColValue("");

commonvo.setPrjassColName(item.getSubitemName());

commonvo.setPrjassColNum(item.getSubitemId() + "");

// Name Code Data Type Primary Foreign Key Mandatory

// 台账项目类型 SUBITEM_TYPE VARCHAR(2) FALSE FALSE TRUE

// 台账项目分类 SUBITEM_ATTR VARCHAR(2) FALSE FALSE TRUE

// 台账项目长度 SUBITEM_LENGTH NUMERIC(14) FALSE FALSE FALSE

// 台账项目是否必输项 SUBITEM_MANDATORY VARCHAR(1) FALSE FALSE TRUE

// 台账项目小数位数 SUBITEM_DIGITS NUMERIC(14) FALSE FALSE FALSE

// 台账项目数据来源 SUBITEM_DATASOURCE VARCHAR(2) FALSE FALSE FALSE

commonvo.setSubItemType(item.getSubitemType());

// commonvo.setSubItemAttr(item.getSubitemAttr());

commonvo.setSubItemLength(item.getSubitemLength());

commonvo.setSubItemMandaTory(item.getSubitemMandatory());

commonvo.setSubItemDigits(item.getSubitemDigits());

commonvo.setSubItemDataSource(item.getSubitemDataSource());

commonvo.setCommonId(item.getSubitemId().toString());

//

commonvo.setItemattr_id(item.getSubitemId().toString());

commonvo.setPlusattr_label("");

commonvo.setPlusattr_value("");

selectPrjassCol.add(commonvo);

}

form.setSelectPrjassCol(selectPrjassCol);

form.setFlag("a");

request.setAttribute("PrjAssActionForm",form);

PrjUtil.printObjValue(form);

return mapping.findForward("showPrjAssEdit");

}

diamondsong
2007-04-19 17:16

jsp代码

<nested:notEmpty property="selectPrjassCol" name="PrjAssActionForm">

<%iRowCount=0;%>

<nested:iterate id="prjassCol" name="PrjAssActionForm" property="selectPrjassCol" indexId="index" type="com.spsoft.project.web.actions.subAccManage.prjPayOut.CommonUseVO" >

<%iRowCount++;%>

<tr id="tr_PlusAttr|<%=iRowCount%>" align="left" class="fieldLabelNeeded" onClick="PlusAttr_OnClick(this);">

<td width="100px" align="right" >

<!-- --><input name="ColName" type="hidden" value="<%=prjassCol.getPrjassColName()%>">

<!--itemattr_id--><input name="itemattr_id" type="hidden" value="<%=prjassCol.getCommonId()%>" size="5">

<!--ITEMATTR_TYPE--><input name="ITEMATTR_TYPE" type="hidden" value="<%=prjassCol.getSubItemType()%>" size="5">

<!--ITEMATTR_LENGTH--><input name="ITEMATTR_LENGTH" type="hidden" value="<%=prjassCol.getSubItemLength()%>" size="5">

<!--ITEMATTR_DIGITS--><input name="ITEMATTR_DIGITS" type="hidden" value="<%=prjassCol.getSubItemDigits()%>" size="5">

<!--ITEMATTR_MANDATORY--><input name="ITEMATTR_MANDATORY" type="hidden" value="<%=prjassCol.getSubItemMandaTory()%>" size="5">

<!--ITEMATTR_DATASOURCE--><input name="ITEMATTR_DATASOURCE" type="hidden" value="<%=prjassCol.getSubItemDataSource()%>" size="5">

<nested:hidden property="prjassColNum" name="prjassCol" ></nested:hidden>

<nested:equal value="Y" name="prjassCol" property="subItemMandaTory">

* <nested:write property="prjassColName" name="prjassCol" ></nested:write>

</nested:equal>

<nested:notEqual value="Y" name="prjassCol" property="subItemMandaTory">

<nested:write property="prjassColName" name="prjassCol" ></nested:write>

</nested:notEqual>

</td>

<td>

<nested:text property="prjassColValue" styleClass="textinput" style="width:0px;"></nested:text>

<input name="plusattr_label" type="text" value="<%=prjassCol.getPlusattr_value()%>" class="textinput" style="width:200px;">

<input name="plusattr_value" type="text" value="<%=prjassCol.getPlusattr_value()%>" class="textinput" style="width:0px;">

<select name="plusattr_YN" style="width:60px;">

<option value="Y" <%if(prjassCol.getCommonValue()!=null && prjassCol.getCommonValue().equals("Y"))out.print("selected");%>>是</option>

<option value="N" <%if(prjassCol.getCommonValue()!=null && prjassCol.getCommonValue().equals("N"))out.print("selected");%>>否</option>

</select>

<select name="plusattr_SPBZ" style="width:60px;">

<option value="01">输电</option>

<option value="02">配电</option>

<option value="03">公用</option>

<option value="04">营销</option>

</select>

<input name="plusattr_btn" type="button" property="button" class="blueButtonCss" value="…" style= "width:20px; margin-right:0px;" >

<input name="plusattr_btnDate" type="button" property="button" class="blueButtonCss" value="…" style= "width:20px; margin-right:0px;" >

</td>

</tr>

</nested:iterate>

</nested:notEmpty>

diamondsong
2007-04-19 17:22

显示是没有问题的,JSP代码也没有问题,问题在nested标签处理list提交的问题,显示正常说明nested展现时运行正确,java.lang.IndexOutOfBoundsException: Index: 5, Size: 0

似乎是在说提交时nested里面的list没有提交过去size=0,但索引却提交过去了index=5;

求各位神仙给小弟指个出路

cscs31
2007-04-20 09:47

这里的人都不喜欢直接看代码,比较喜欢说道理

2Go 1 2 下一页