2017-03-18 22:55

肯定是用拦截器合适啊! 你那个继承然后加些成员变量才不好, 都强绑定了! 拦截器直接把需要的参数set到需呀的地方, 需要和不需要就@下, 多方便啊

2017-03-14 16:25

@Irin.Chan 是啊用了代码格式, 就不能画底色了, 所以我放弃了用代码格式, 用这个底色主要是划重点, 然后再去看源码会有轻松些

2017-03-06 10:51

protected List whereParams = new ArrayList();

whereParams 又不是静态的, 所以不是它的锅,
我猜想 是你调用了 静态的 dao Model对象吧? 所以whereParams 就混乱了,
推荐你参考一下JFinalUIB的分页封装,写的挺好!

哥! 你得复习一下Java的多态,不然后面会遇到很多不必要的坑,
PS: 用LinkedList 是不是会好些啊?

2017-03-04 09:37

Db.update("sql"); 只要连接数据库的帐号权限够, 建库建表 语句 都可以执行的!

2017-03-04 09:33

model.keep(attr...);//保留哪些
model.remove(attrs...);//删除哪些

2017-03-04 09:23

创建的me对象是静态得, 多线程对静态方法的访问,是交叉执行的.
而且 .dao(); 方法能保证 me对象 只会被用来查询使用, 所以就不会有操作成员变量的情况,

2017-02-27 14:36

以我的脾气: rm -rf * 2333333333

2017-02-11 19:35

您现在应该访问:
http://localhost:8080/jfinal_demo/bolg
才对的, 因为你加了项目名称前缀,

MyEclipse , 建议先 修改 你的 Tomcat 配置 :

如我的: (因为过滤的关系, 以下"<""\" 以 "" 包裹 )
文件: F:\apache-tomcat-7.0.56\conf\server.xml
从后往前找: "<"/Host">" 这个标签, 在它前面加入:(记得加 WebRoot )

"<"Context docBase="F:\workspace\jfinal_3.0\WebRoot" path="" reloadable="false"/">"
"<"反斜杠Host">"


然后 再回到你 的MyEclipse 启动  Tomcat 就好了,

2017-02-09 15:23

@zhaozhihong 你肯定没有 BaseXxx, fastjson 里面是裁了 getXxx,setXxx 的三个字符.... 所以它就能知道需要put 哪些东西

2017-02-09 15:17

@杜福忠 ps : 上面的方法依赖于 BaseBlog 也就是 JavaBean, 得有getXxx,setXxx

2017-02-09 15:09

@JFinal 老大,上面的使用方式 有不妥的地方吗?

2017-02-09 15:05

实践出真"汁"...

public static void main(String[] args) {
PropKit.use("a_little_config.txt");
DruidPlugin dp = DemoConfig.createDruidPlugin();
ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
arp.addMapping("blog", Blog.class);
// 与web环境唯一的不同是要手动调用一次相关插件的start()方法
dp.start();
arp.start();
// 通过上面简单的几行代码,即可立即开始使用
new Blog().set("title", "title1").set("content", "cxt text").save();
new Blog().set("title", "title2").set("content", "cxt text").save();

//--------------------------------------------------------------------
// ----- 使用 fastjson 互转
Blog blog = Blog.me.findById(1);

//----- 使用 JsonKit : 类 转 json
String blogJson = blog.toJson();

System.out.println("blogJson:\t" + blogJson);

//----- 使用 fastjson : json 转 类
Blog parseObject = JSONObject.parseObject(blogJson, Blog.class);

System.out.println("parseObject.toJson(): \t" + parseObject.toJson());

//---------------------------------------------------------------------

List blogByAll = Blog.me.queryByAll();

//----- 使用 JsonKit : 类集合 转 json集合
String blogByAllJson = JsonKit.toJson(blogByAll);
System.out.println("blogByAllJson: \t" + blogByAllJson);

//----- 使用 fastjson : json集合 转 类集合
List jsons = JSONArray.parseArray(blogByAllJson, Blog.class);

for (Blog parse : jsons) {
System.out.println("List for : \t" + parse.toJson());
}
}

2017-02-08 16:36

enhance(Order.class).dealOrder() 这样写只能在Controller中使用, 因为在Controller中已经有这个方法了,所以您的Controller 就继承了!
Controller源码1237行以后, 这样写到:
public T enhance(Class targetClass) {
return (T)Enhancer.enhance(targetClass);
}


在任意的位置是这样调用的:
Enhancer.enhance(Order.class).dealOrder()


如手册第 4.6 Duang 、Enhancer 章的 例子:
public class TestMain{
public void main(String[] args) {
// 使用Duang.duang方法在任何地方对目标进行增强
OrderService service = Duang.duang(OrderService.class);
// 调用payment方法时将会触发拦截器
service.payment(…);
// 使用Enhancer.enhance方法在任何地方对目标进行增强
OrderService service = Enhancer.enhance(OrderService.class);
}
}