日期:2014-05-20 浏览次数:20617 次
-----------------------JS代码 function checkCardNo(obj){ shuzi(obj); if(obj.value.length > 0){ $.ajax({ type: "POST", url: "checkJson/checkCardNo.action", data: {"searchWord":obj.value}, dataType:"json", success: function(json){ var nulldTag = json.nullTag; if(nulldTag=="N"){ alert("卡号已存在!"); $("#ticNo").val(""); $("#ticNo").focus(); return false; } }, error:function(a,b,c){ alert(a.status + " " + c); } }); } }
---------------------------struts2代码 @ParentPackage(value="json-default") @Namespace("/checkJson") @Results({ @Result(name = "success",type="json") }) @Action(value="checkCardNo") public String checkCardNo(){ this.list = this.infCardService.findCard(null, this.searchWord,this.getPageNo(), -1); if (this.list != null && this.list.size() > 0) { this.nullTag = "N"; }else{ this.nullTag = "Y"; } return SUCCESS;//走到这里nullTag是有值的。我抓了一张调试的图,但是发不上来。。。 } private String nullTag; @JSON(name="nullTag") public String getNullTag() { return nullTag; } public void setNullTag(String nullTag) { this.nullTag = nullTag; }