1 @RequestMapping("/check/{param}/{type}") 2 @ResponseBody 3 public Object checkData(@PathVariable String param, @PathVariable Integer type, String callback) { 4 5 TaotaoResult result = null; 6 7 // 参数有效性校验 8 if (StringUtils.isBlank(param)) { 9 result = TaotaoResult.build(400, "校验内容不能为空"); 10 } 11 if (type == null) { 12 result = TaotaoResult.build(400, "校验内容类型不能为空"); 13 } 14 if (type != 1 && type != 2 && type != 3) { 15 result = TaotaoResult.build(400, "校验内容类型错误"); 16 } 17 // 校验出错 18 if (null != result) { 19 if (null != callback) { 20 JSONPObject jsonpObject = new JSONPObject(callback, result); 21 return jsonpObject; 22 } else { 23 return result; 24 } 25 } 26 // 调用服务 27 try { 28 result = userService.checkData(param, type); 29 30 } catch (Exception e) { 31 result = TaotaoResult.build(500, ExceptionUtil.getStackTrace(e)); 32 } 33 34 if (null != callback) { 35 JSONPObject jsonpObject = new JSONPObject(callback, result); 36 return jsonpObject; 37 // MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(result); 38 // mappingJacksonValue.setJsonpFunction(callback); 39 // mappingJacksonValue.setValue(callback); 40 // return mappingJacksonValue; 41 } else { 42 return result; 43 } 44 }