求各位帮小弟看一下这个问题!
DaoImpl:
public int muiltDelete(List<Long> ids) {
return getSession().update("com.ningpai.web.dao.TraceLogMapper.deleteMultiByLogId", ids);
}
Service:
public int multiDeleteByIds(Long[] ids){
List<Long> list=new ArrayList<Long>();
for(int i=0;i<ids.length;i++){
list.add(ids[i]);
}
return traceLogDao.muiltDelete(list);
}
Controller:
@RequestMapping("/multiDeleteTraceLog")
public ModelAndView multiDelete(HttpServletResponse response,Long[] Id){
PrintWriter pr=null;
try {
response.setContentType(Constant.REQ_SETCONTENT);
pr=response.getWriter();
pr.print(traceLogService.multiDeleteByIds(Id));
} catch (IOException e) {
return new ModelAndView(Constant.REQ_VIEW);
}finally{
if(pr!=null){
pr.close();
}
}
return null;
}
SQL语句:
<update id="deleteMultiByLogId">
UPDATE trace_log SET delete_flag='1' WHERE
<foreach collection="list" separator="or" item="mid" index="index" >
(id = #{mid,jdbcType=BIGINT})
</foreach>
</update>
运行批量删除后报错:
Resolving exception from handler [com.ningpai.web.productrecord.controller.TraceLogController@335578c5]: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long[]'; nested exception is java.lang.NumberFormatException: For input string: "undefined"
求各位大神帮小弟看一下,是哪儿错了,拜谢! 异常
[解决办法]
这样,你找找
Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long[]'; nested exception is java.lang.NumberFormatException: For input string: "undefined"
这里说错误是你想把undefined转化为long的形式,所以出错,
我猜应该是你某个值未赋值,所以前台页面默认添加了undefined
[解决办法]
debug看一下页面哪个input 未赋值
[解决办法]
string 转long异常 仔细找找哪转换错了
[解决办法]
string 未定义
[解决办法]
<update id="deleteMultiByLogId">修改为<update id="deleteMultiByLogId" parameterType="array">试下。