zoukankan      html  css  js  c++  java
  • jquery 前端 跨域 jsonp

    1、jsonp 支持get;可以跨域;

    2、java 在controller中增加header:

     /**
         * 获取用户信息
         */
        @ResponseBody
        @RequestMapping(value = "/user/getuserInfo", method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
        public String getUserInfo(@RequestParam Map<String, Object> paramMap, HttpServletRequest request
        , HttpServletResponse response) {
           // response.addHeader("Access-Control-Allow-origin","localhost");
            response.addHeader("Access-Control-Allow-Credentials","true");
            response.addHeader("Access-Control-Allow-Methods","POST,GET,OPTIONS,PUT,DELETE");
            response.addHeader("Access-Control-Allow-Headers","cache-control,content-type,hash-referer,x-requested-with");
            log.info("get the /user/getInfo request data : " + paramMap.get("userId").toString());
            JsonResultEx result = new JsonResultEx();
    
            String username = paramMap.get("userId").toString();
    }
    

      

    www.beicaiduo.com
  • 相关阅读:
    sed&awk 资料汇总 全是链接
    LeetCode Path 3Sum
    C++ mem_fun
    递归绑定
    查询当天数据
    清除script注入
    防注入查询
    我的最新分页
    群发邮件
    利用缓存
  • 原文地址:https://www.cnblogs.com/hoge66/p/10422358.html
Copyright © 2011-2022 走看看