首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

struts2、Spring3.0、mybatis整合有关问题,

2013-06-25 
struts2、Spring3.0、mybatis整合问题,求助~~~~~~~~~求助~~~~~~~~~想做一个批量提交插入数据库,不过老是报空

struts2、Spring3.0、mybatis整合问题,求助~~~~~~~~~求助~~~~~~~~~
想做一个批量提交插入数据库,不过老是报空指针,求大神帮忙瞅瞅,下面贴代码
JSP代码:

<s:iterator value="listTmManage" status="s">
  <tr class="row" onmouseover="this.className='overrow'" onmouseout="this.className='row'" align="center">
  <input type="hidden" name="tmManageExs[<s:property value="#s.index" />].id" />
      <td><s:property value="#s.index+1" /></td>
      <td><input type="text" id="tmmanageex.tm_id" name="tmManageExs[<s:property value="#s.index" />].tm_id" value="<s:property value="id" /> "/></td>
      <td><input type="text" id="tmmanageex.tz_id" name="tmManageExs[<s:property value="#s.index" />].tz_id" value="<s:property value="tz_id" />"/></td>
      <td><input type="text" id="tmmanageex.record_id" name="tmManageExs[<s:property value="#s.index" />].record_id" value="${tzmanageex.record_id}" /></td> 
      <td align="left"><s:property value="tm_title" /></td>
      
      <td><input type="radio" id="tmmanageex.score" name="tmManageExs[<s:property value="#s.index" />].score" value="1" /> </td>
      <td><input type="radio" id="tmmanageex.score" name="tmManageExs[<s:property value="#s.index" />].score" value="2" /> </td>
      <td><input type="radio" id="tmmanageex.score" name="tmManageExs[<s:property value="#s.index" />].score" value="3" /> </td>
      <td><input type="radio" id="tmmanageex.score" name="tmManageExs[<s:property value="#s.index" />].score" value="4" /> </td>
      <td><input type="radio" id="tmmanageex.score" name="tmManageExs[<s:property value="#s.index" />].score" value="5" /> </td> 
   </tr>
   
  </s:iterator>

Action

public String subscore() throws Exception{
  for(TmManageEx tmmanageex : tmManageExs){
  this.tmManageExService.saveTmManageEx(tmmanageex, this.getUserInfo());
  }
  
       if (UtilAPI.isNull(tmmanageex)){throw new BusinessException("找不到该记录");}
      return SUCCESS; 
  }
Spring MyBatis Struts Java
------解决方案--------------------


用debug不就能找到答案吗?
[解决办法]
空指针也分很多种啊。
你既然用到Spring,那么首先你确定Mybatis对象注入成功了?
如果成功,好,再看MyBatis中所需的sql语句配置文件中是否有对应?
还没有问题的话,那么你看输入的值得类型是否匹配呢?
[解决办法]
起码把异常信息帖出来吧,这怎么看?

热点排行