标签:系统 cal service class error 跨域请求 item ace utils
@Controller
@RequestMapping(value = "api")
public class ApiItemCatController {
@Autowired
private ItemCatService itemCatService;
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<String> queryItemCatAll(@RequestParam(value="callback",required =false)String callback) {
try {
// 调用service 查询
ItemCatResult result = itemCatService.queryItemCatAll();
ObjectMapper mapper = new ObjectMapper();
String jsonResult = mapper.writeValueAsString(result);
//判断是否是跨域请求
if(StringUtils.isNotEmpty(callback)){
return ResponseEntity.ok(callback + "("+jsonResult+")");
}
// 如果不是,直接返回结果和成功状态码
// 返回结果和状态码
return ResponseEntity.status(HttpStatus.OK).body(jsonResult);
} catch (Exception e) {
e.printStackTrace();
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(
null);
}
}
=================================================================================================================
另一个系统的url :http://manage.taotao.com/rest/api/item/cat?callback=category.getDataService
标签:系统 cal service class error 跨域请求 item ace utils
原文地址:http://www.cnblogs.com/ronniery/p/7186531.html