问题描述
varinsId=$("#insId").val();varinsName=$("#insName").val();varinsMade=$("#insMade").val();varinsSeller=$("#insSeller").val();varinsBuyPrice=$("#insBuyPrice").val();varinsSellPrice=$("#insSellPrice").val();alert(insId+""+insName+""+insMade+""+insSeller+""+insBuyPrice+""+insSellPrice)$.get("saveUpdate.action?t="+newDate(),{"insId":insId,"insName":insName,"insMade":insMade,"insSeller":insSeller,"insBuyPrice":insBuyPrice,"insSellPrice":insSellPrice},function(data){alert("更新数据成功");});
//Action里面SaveUpdateListEntitysaveUpdate=newSaveUpdateListEntity();saveUpdate.setInsId(Integer.parseInt(insId));saveUpdate.setInsName(insName);saveUpdate.setInsMade(insMade);saveUpdate.setInsSeller(insSeller);saveUpdate.setInsSellPrice(Double.parseDouble(insSellPrice));saveUpdate.setInsBuyPrice(Double.parseDouble(insBuyPrice));this.getAllService().getUpdateService().saveUpdateList(saveUpdate);ServletActionContext.getResponse().setContentType("text/html");ServletActionContext.getResponse().setCharacterEncoding("utf-8");ServletActionContext.getResponse().getWriter().printf("success");ServletActionContext.getResponse().getWriter().flush();ServletActionContext.getResponse().getWriter().close();
问题是saveUpdate里面的值都是null而saveUpdate.setInsName(insName);里面从页面传过来的有值我想这里不能这么new实体么?还是什么原因!
解决方案
解决方案二:
你的意思是insName有值,saveUpdate.setInsName之后,savaUpadate实体中值还为空?
解决方案三:
你在后台用Stringaa=request.getParameter('insId');先看下aa有值没如果是null的话说明你的参数就没传到后台或者说你的struts的action没有写好
解决方案四:
saveUpdate.setInsName(insName);saveUpdate.setInsMade(insMade);saveUpdate.setInsSeller(insSeller);saveUpdate.setInsSellPrice(Double.parseDouble(insSellPrice));saveUpdate.setInsBuyPrice(Double.parseDouble(insBuyPrice));这些都拿到了!this.getAllService().getUpdateService().saveUpdateList(saveUpdate);saveupdate里面的值都null最后的赋值
解决方案五:
那就说名saveUpdate这个javabean是没有问题的不是这个实体的问题saveUpdateList这个方法发上来看下
解决方案六:
publicvoidsaveUpdateList(SaveUpdateListEntitysuleRef){InsListinsList=this.getAlldao().getInsListDao().findById(suleRef.getInsId());insList.setInsName(suleRef.getInsName());insList.setInsMade(suleRef.getInsMade());insList.setInsSeller(suleRef.getInsSeller());insList.setInsBuyPrice(suleRef.getInsBuyPrice());insList.setInsSellPrice(suleRef.getInsSellPrice());this.getAlldao().getInsListDao().attachDirty(insList);}
解决方案七:
其实从你的这些代码上看都是不应该有问题的publicvoidsaveUpdateList(SaveUpdateListEntitysuleRef){//参数suleRef这个没有问题是肯定的InsListinsList=this.getAlldao().getInsListDao().findById(suleRef.getInsId());insList.setInsName(suleRef.getInsName());insList.setInsMade(suleRef.getInsMade());insList.setInsSeller(suleRef.getInsSeller());insList.setInsBuyPrice(suleRef.getInsBuyPrice());insList.setInsSellPrice(suleRef.getInsSellPrice());//这个insList到这里也应该是更新ok了this.getAlldao().getInsListDao().attachDirty(insList);//这个就得看sql了呵呵}
解决方案八:
你action里面写的都是什么啊?麻烦贴出来看看!