1.DAO層Service層
2.改造Controller層
導入fastjson.jar包
@ResponseBody
//判斷使用者編碼是否存在
public Object userCodeIsExit(@RequestParam String userCode){
HashMap<String,String> resultMap=new HashMap<String,String>();
if(StringUtils.isNullOrEmpty(userCode)){
resultMap.put("userCode","exist");
}
else
{
User user=userService.selectUserCodeExist(userCode);
if(null!=user){
resultMap.put("userCode","exist");
}
else
{
resultMap.put("userCode","noexist");
}
return JSONArray.toJSONString(resultMap);
}
}
3.View層 用Ajax通路