JFinal ajax 跨越请求 jsonp
来源:互联网 发布:js object 属性个数 编辑:程序博客网 时间:2024/04/30 14:24
<p>通过JFinal 框架,ajax跨域请求。</p><p>后台代码:</p><p><pre name="code" class="java"> public void dologin() { JSONObject json = new JSONObject(); Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(getPara("account"), EncryptionKit.md5Encrypt(getPara("password"))); try { // 4、登录,即身份验证 subject.login(token); String from = getPara("from"); String findSql = "(1=1) and "; // 获取信息 String account = token.getUsername(); if (account != null) findSql += "account like '" + account + "' and "; findSql += " (1=1);"; SysUser data_need = SysUser.dao.where(findSql).get(0); int Id = data_need.getInt("id"); json.put("id", Id); json.put("account", Account); if ("1".equals(is_app)) { //app端登录session不过期 subject.getSession(true).setTimeout(-1); renderJson("jsonpCallback({\"data\":"+json.toJSONString()+"})"); // renderJson(putjson("0", data, "success")); } else { subject.getSession(true).setTimeout(60*60*1000); if (StringKit.isBlank(from)) redirect("/"); else { redirect(from); } } } catch (AuthenticationException e) { // 5、身份验证失败 if ("1".equals(is_app)) { renderJson(putjson("330", "", "failed")); } else { alertAndGoback("用户名或密码错误,请重新登录"); } } }
前台代码:
function doLogin(account,password){$.ajax({url : "http://localhost:10080/Passport/dologin",//baseURLdata : {is_app : 1,account : account,password : password,},type : "post",//crossDomain: true,dataType : "jsonp",jsonp : "callback",jsonpCallback:"jsonpCallback",success : function(data) {var temp = (data.data.id);location.href="http://www.baidu.com";},error : function(XMLHttpRequest, textStatus, errorThrown) {alert(XMLHttpRequest.status);return false;} });}
0 0
- JFinal ajax 跨越请求 jsonp
- jsonp的跨越请求
- jsonp + php 跨越请求
- 同源策略、跨越请求和JSONP
- 同源策略、跨越请求和JSONP
- AJAX请求跨越问题-解决方案
- ajax 异步请求 jsonp
- ajax跨域请求jsonp
- AJAX - 跨域请求 && JSONP
- ajax跨域请求jsonp
- ajax跨域请求jsonp
- JSONP跨域请求AJAX
- Ajax跨域请求--Jsonp
- jfinal jquery解决ajax 跨域访问--jsonp
- ajax(jsonp)发送ajax跨域请求
- 跨越请求
- Java服务端设置CORS跨越请求,Ajax跨越请求服务器设置
- jquery中jsonp的ajax请求
- 【maven学习】——(1)简单入门
- unity 协程原理与线程的区别
- 五金配件行业ERP解决方案
- 项目2-程序的多文件组织
- 用Mysql获得每年每月的内容及replace
- JFinal ajax 跨越请求 jsonp
- 使用 gradle 编译多版本 android 应用
- 一个项目调用另一个项目接口,传递json参数
- IL2CPP 深入讲解:P/Invoke封装(三)
- 在正文中提取有实际意义的数字
- Android中对设备进行管理的一些方法(获取设备唯一标识码、设备分辨率信息等)
- Could not get BatchedBridge, make sure your bundle is packaged properly
- 通过与Java的比较,迅速掌握Groovy
- JAVA产生一个十位的随机数