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 }