2018-11-15 19:18

@JFinal 波总,我发现问题了,是我项目写了个controller层的基类,只要继承该基类,重写父类public的方法,都会出现此错误,把父类的修改为非public的即可解决。我建议重写的方法,您再给路由表映射的时候,只注册一次,不要父类和子类的都进行注册!个人建议!

2018-11-15 15:57

2017-05-16 06:52

@爪爪 重新封装之后的能分享出来学习学习吗?

2017-05-13 13:27

@JFinal 有没有类似spring对mq连接池的管理 等等

2017-04-28 18:17

@JFinal
我们用的db2,我因为在config配置了
ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
arp.setContainerFactory(new PropertyNameContainerFactory());

PropertyNameContainerFactory 类(新增类PropertyNameContainerFactory 驼峰下划线工厂类)代码如下:

package com.cmpl.jxgl.common;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.jfinal.plugin.activerecord.IContainerFactory;

//XXX 新增类PropertyNameContainerFactory 驼峰下划线工厂类
@SuppressWarnings({ "rawtypes", "unchecked" })
public class PropertyNameContainerFactory implements IContainerFactory {

public Object convert(Object key) {
if (key instanceof String) {
String property = null;
String alias = null;
if (((String) key).indexOf(".") > -1) {
String[] properties = ((String) key).split("\\.");
alias = properties[0];
property = properties[1];
} else {
property = ((String) key);
}
StringBuilder buf = new StringBuilder(property);
for (int i = 1; i < buf.length() - 1; i++) {
if (Character.isLowerCase(buf.charAt(i - 1)) && Character.isUpperCase(buf.charAt(i))
&& Character.isLowerCase(buf.charAt(i + 1))) {
buf.insert(i++, '_');
}
}
return (alias != null ? alias + "." : "")
+ (toUpperCase ? buf.toString().toUpperCase() : buf.toString().toLowerCase());
}
return key;
}

private static boolean toUpperCase = true;

public PropertyNameContainerFactory() {
}

public PropertyNameContainerFactory(boolean toUpperCase) {
PropertyNameContainerFactory.toUpperCase = toUpperCase;
}

public Map getAttrsMap() {
return new PropertyNameMap();
}

public Map getColumnsMap() {
return new PropertyNameMap();
}

public Set getModifyFlagSet() {
return new PropertyNameSet();
}

public class PropertyNameSet extends HashSet {
private static final long serialVersionUID = 2337255096474815584L;

public boolean add(Object e) {
return super.add(convert(e));
}

public boolean remove(Object e) {
return super.remove(convert(e));
}

public boolean contains(Object e) {
return super.contains(convert(e));
}

public boolean addAll(Collection c) {
boolean modified = false;
for (Object o : c)
if (super.add(convert(o)))
modified = true;
return modified;
}
}

public class PropertyNameMap extends HashMap {
private static final long serialVersionUID = -4107018318847768335L;

public Object get(Object key) {
return super.get(convert(key));
}

public boolean containsKey(Object key) {
return super.containsKey(convert(key));
}

public Object put(Object key, Object value) {
return super.put(convert(key), value);
}

public void putAll(Map m) {
for (Map.Entry e : (Set) (m.entrySet()))
super.put(convert(e.getKey()), e.getValue());
}

public Object remove(Object key) {
return super.remove(convert(key));
}
}
}


这样我通过如下方法调用:
Page page =Db.paginate(1, 10, "select * ", " from hello_word a ");
renderJson(JFinalJson.getJson().toJson(page));

返回的数据如下:
{"totalRow":2,"pageNumber":1,"lastPage":true,"firstPage":true,"totalPage":1,"pageSize":10,"list":[{"NUAN_NUAN":"test","ID":"11111111111111111110","USER_NAME":"张三","USER_PWD":"李四"},{"NUAN_NUAN":"1","ID":"11111111111111111111","USER_NAME":"1","USER_PWD":"111"}]}


因为我们业务表很多,牵扯到数据移植,所以字段名称不能调整。

2017-04-28 17:22

大神考虑问题真细,越来越喜欢了!

2017-04-28 17:09

@JFinal 非常感谢,感激!已经好用!

2017-04-26 09:34

@JFinal 非常感谢!早上发的,您一大早都给回复了!感动!