js跨域实例

来源:互联网 发布:淘宝与天猫有什么区别 编辑:程序博客网 时间:2024/06/16 13:16
java后台代码
@RequestMapping(value = "/CipherLogon",method = RequestMethod.GET)    @ResponseBody    public String CipherLogon() {        ParmMap parmMap =new ParmMap();        Map map = new RetMap();        String result ;        HashMap infoMap = new HashMap();        HttpSession session = this.getRequest().getSession();        String code= this.getRequest().getParameter("code");//        String  callback=this.getRequest().getParameter("callback");        User user = null;        try {            code= Cipher.dencrypt(code);        } catch (Exception e) {            e.printStackTrace();        }        parmMap.put("userName",code);        List<User> userInfoBOList = iuserInfoService.selectUserByUsername(parmMap);        if (userInfoBOList.size() == 1) {            for (int i = 0; i < userInfoBOList.size(); i++) {                user = userInfoBOList.get(i);            }            if (user != null) {                session.setAttribute(SESSION_USER, user);                infoMap = iuserInfoService.queryUserRoleInfo(user); //查询用户权限信息                String userId = user.getUserId();                System.out.println(userId + infoMap);                byte[] bytes=SerializationUtil.serialize(infoMap);                RedisUtil.set(SerializationUtil.serialize(userId), SerializationUtil.serialize(infoMap));//将用户权限信息放入缓存            }            map.put("data", "success");            result= "{'data':'success'}";        } else {            map.put("data", "error");            result= "{'data':'error'}";        }        String jsonp = "CipherLogonReturn" + "(" + result + ")";        return jsonp;    }


js前端代码

    function CipherLogonReturn (data){        alert(data.data);        type=data.data;    }
<script type="text/javascript" src="http://192.168.43.215:8080/mbp/CipherLogon?callback=CipherLogonReturn&code=${code}"></script>



原创粉丝点击