zoukankan      html  css  js  c++  java
  • jsonp使用

    jsp页面:

    $.ajax({
    type:"get",
    dataType:"jsonp",
    url: http://www.cgh.com:9091/cmis-web2/cookie/setCookie.do?cookieVal=dgrr556fghjcvn56667889hkdbj,
    jsonp: 'callback',
    crossDomain:true,
    success: function(data){
       alert(data.code);
    },
    beforeSend:function(){
    },
    complete:function(data,status){
    },
    error:function(){
    alert("system error!");
    }
    });

    后台接收:

    @Controller
    @RequestMapping("cookie")
    public class CookieSetController {
    @RequestMapping(value = "setCookie.do")
    public @ResponseBody String setCookie(HttpServletRequest request, HttpServletResponse response,
    @RequestParam(value = "cookieVal") String cookieVal,String callback) {
    ResultModel resultModel = new ResultModel();
    try {
    response.addHeader("P3P", "CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR");
    Cookie cookie = new Cookie(ComContants.CK_SESSIONID, cookieVal);
    cookie.setPath("/");
    response.addCookie(cookie);
    resultModel.setCodeToSuccessed();

    } catch (Exception e) {
    e.printStackTrace();
    resultModel.setCode(ResultModel.ERROR_CODE, e.getMessage());
    }
    return callback+"("+JsonConvert.toJSON(resultModel)+")";
    }

    }

  • 相关阅读:
    数论
    平衡树
    矩阵儿快速幂
    分治
    考试
    考试
    匈牙利算法
    SPFA
    倍增
    MySql 技术内幕 (数据库组成和引擎)
  • 原文地址:https://www.cnblogs.com/cghhnty/p/7665762.html
Copyright © 2011-2022 走看看