zoukankan      html  css  js  c++  java
  • Jsonp跨域调用


    @Autowired
    private UserService userService; // 请求方法 GET // URL http://sso.taotao.com/user/check/{param}/{type} /** * 检查数据是否可用 * * @param param * @param type * @return */ @RequestMapping(value = "check/{param}/{type}", method = RequestMethod.GET) // @ResponseBody public ResponseEntity<String> check(HttpServletRequest request, @PathVariable String param, @PathVariable Integer type) { try { Boolean bool = this.userService.check(param, type); // 1.获取callback参数 String callback = request.getParameter("callback"); // 2.判断callback是否为非空 String result = ""; if (StringUtils.isNotBlank(callback)) { // 如果为非空,则进行伪装 // 3.对返回结果进行包裹,伪装成js数据fun(true) result = callback + "(" + bool + ")"; } else { // 如果为空,不伪装,直接返回 result = "" + bool; } // 这就是一个查询,返回200 return ResponseEntity.ok(result); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // 如果服务器错误,返回500 return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null); }

    把泛型由Boolean改为String。

  • 相关阅读:
    移动采编app
    分布式自动化测试
    appium --log-timestamp > appium.log
    处理安卓的弹窗
    Sublime text3修改tab键为缩进为四个空格
    安卓自动化测试——rf
    敏捷软件开发
    photoshop怎么旋转图片
    thinkPHP5.0模型实现软删除
    thinkPHP5.0数据查询表达式生成技巧
  • 原文地址:https://www.cnblogs.com/javaxiaoxin/p/7635923.html
Copyright © 2011-2022 走看看