2018-03-23 22:19
默认JFinalJson工具转 model 时 是不支持自定义属性的,
if (value instanceof Model) {
Map map = com.jfinal.plugin.activerecord.CPI.getAttrs((Model)value);
return mapToJson(map, depth);
}
if (value instanceof Record) {
Map map = ((Record)value).getColumns();
return mapToJson(map, depth);
}
/** com.jfinal.plugin.activerecord.CPI.getAttrs
* Return the attributes map of the model
* @param model the model extends from class Model
* @return the attributes map of the model
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static final Map<String, Object> getAttrs(Model model) {
return model._getAttrs();
}
public class Node extends BaseNode<Node> {
public String getDeviceChannel() {
return get("deviceChannel");
}
public void setDeviceChannel(String deviceChannel) {
put("deviceChannel ", deviceChannel)
}
}
2018-03-22 21:41
@AndrewTseng 分享的一个小玩意 JFinal使用技巧-Enjoy导出XLS
2018-03-21 22:37
不贴代码 .. 能猜出来才怪.... 提问题时还是需要站在别人的角度看下吧 ..
我猜有可能是你 tomcat 配的有问题 :
JFinal 部署在 Tomcat 下推荐方法
"记住第一点,永远不要将项目放在 TOMCAT_HOME/webapps 目录下面"
2018-03-14 23:10
方法一
拦截器
inv.getController().getResponse().addHeader("Access-Control-Allow-Origin", "*");//指定域名
方法二
1, JFinal的Controller返回的时候如下:
这里的content就是我的Json字符串
renderJson("innerSignCallBack(" + content + ")");//跨域的请求,jsonp
2, 页面的Ajax如下:
var url = 'http://xxx.com/getJson';
$.ajax({
type : "get", //必须get,不填也行
url : url,
dataType : "jsonp",
jsonp:'innerSignCallBack', //服务器端获取回调函数名的key
jsonpCallback:'innerSignCallBack', //回调函数名
success:function(data) { //成功
alert('成功')
},
error : function(msg) {//失败
alert('失败');
}
});