Struts参数名称的Bug

来源:互联网 发布:康泰尔a1 数据 编辑:程序博客网 时间:2024/05/19 19:39

 

Struts参数名称的Bug

 

 

          应用Struts架构的web程序员越来越多,但不知道你们是否遇到过,在写jsp页面时,需要提交到表单中的参数名并不是所有的名字都可取。

          之前,基于struts写得jsp页面,应该不算少了,一直没有遇到,直到昨天,修改一个别人程序里的bug,调试了半天,发现,原来struts对有些参数名称的处理有问题。

<logic:iterate id="view" name="compensationBalanceForm" property="listChunk.collection" indexId="index"              type="com.neusoft.ehr.business.compensation.balance.BalanceViewVO" >
    <tr class="<%=(index.intValue() % 2 == 0) ? "alternateA" : "alternateB"%>">
      <td nowrap><bean:write name="view" property="employeeCode"/></td>
      <td nowrap><bean:write name="view" property="employeeName"/></td>
      <td nowrap><bean:write name="view" property="year"/></td>
      <td nowrap><html:text name="view" property="value" onchange="javascript:changeValue   (this.value)" /></td>
      <td>
       <a href="javascript:viewUpdate(<bean:write name="view" property="oid"/>)">
           <bean:message bundle="compensation" key="cb.policy.edit.editMode.replace"/>
       </a>
      </td>
    </tr>
</logic:iterate>

上面这段代码在提交时,就会出现问题,系统运行在struts处理时就出了问题,根本到不了我们自己的系统就停了 。org.apache.commons.beanutils.BeanUtils 类在处理参数时出现了问题。

下面是该jsp文件编译后的java文件对应部分代码:

private boolean _jspx_meth_html_text_5(javax.servlet.jsp.tagext.Tag _jspx_th_logic_iterate_0, javax.servlet.jsp.PageContext pageContext)
          throws Throwable {
    JspWriter out = pageContext.getOut();
    /* ----  html:text ---- */
    org.apache.struts.taglib.html.TextTag _jspx_th_html_text_5 = (org.apache.struts.taglib.html.TextTag) _jspx_tagPool_html_text_property_onchange_name.get(org.apache.struts.taglib.html.TextTag.class);
    _jspx_th_html_text_5.setPageContext(pageContext);
    _jspx_th_html_text_5.setParent(_jspx_th_logic_iterate_0);
    _jspx_th_html_text_5.setName("view");
    _jspx_th_html_text_5.setProperty("value");
    _jspx_th_html_text_5.setOnchange("javascript:changeValue(this.value)");
    int _jspx_eval_html_text_5 = _jspx_th_html_text_5.doStartTag();
    if (_jspx_th_html_text_5.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE)
      return true;
    _jspx_tagPool_html_text_property_onchange_name.reuse(_jspx_th_html_text_5);
    return false;
  }

运行时,后提示Property : "value"  has not set Method  !!!       从表面看不应该有错误。如果我们在这里将value 修改为其他名字,比如  "valueSecond" ,并修改相应业务方法后,从新运行系统,一切正常了。这就是strut在组装表单时,对参数名为“value”的处理的不正确。

希望大家看了后不要再来这里浪费时间调试!!!

coolwangyu@Gmail.com 

原创粉丝点击