2023-09-05 22:48

@zzutligang [ 是一层,{ 也是一层,所以 数组 套 map 是两层。并不是只算 { map对象

2023-08-29 21:45

我也懵逼,要不贴点代码?我测试没问题呀
public static void main(String[] args) {
Okv base = null;
Okv dad = null;
String[] kin = {"媳妇", "弟弟", "妹妹"};
List<String> riches = Arrays.asList(new String[]{"房子", "车子", "票子"});

for (int i = 0; i <= 20; i++) {
Okv son = Okv.of("name", "杜" + i);
son.set("kin", kin);
son.set("riches", riches);
if (base == null){
base = son;
}else {
dad.set("son", son);
}
dad = son;
}
JFinalJson.setDefaultConvertDepth(18);
String json = JFinalJson.getJson().toJson(base);
System.out.println(json);
}
{"name":"杜0","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜1","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜2","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜3","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜4","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜5","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜6","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜7","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜8","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜9","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜10","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜11","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜12","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜13","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜14","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜15","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜16","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜17","kin":["媳妇","弟弟","妹妹"],"riches":["房子","车子","票子"],"son":{"name":"杜18","kin":null,"riches":null,"son":null}}}}}}}}}}}}}}}}}}}

2023-08-29 16:26

BigDecimal.class 已经内置,需要先移除再添加
Engine.removeExtensionMethod(BigDecimal.class, new BigDecimalExt());
Engine.addExtensionMethod(BigDecimal.class, new MyBigDecimalExt());

2023-08-14 16:12

@chcode 是嘞,自己封装一个分页方法再转调工具类也很方便了

2023-08-13 18:19

PS: https://gitee.com/o88o/psi
貌似 /src/main/webapp 目录下的前端文件没上传了。
Java代码很整洁,注释也很齐!个人用户很好的学习练手项目啊

2023-08-13 17:47

@Leo.du 执行ActionHandler 的时候 才创建 JsonRequest对象,自定义的 Handler 是在ActionHandler 之前执行的,所以是拿不到的。

需求分析:根据你业务需求,是要获取 JsonRequest ,并且是 Handler 级的获取。
简单方案:创建JsonRequest 的时候,获取该对象,因为ActionHandler 支持setJsonRequestFactory。代码大致如下:JFinalConfig的子类》
public void configConstant(Constants me) {
me.setResolveJsonRequest(true);
me.setJsonRequestFactory((jsonString, req) -> {
JsonRequest ret = new JsonRequest(jsonString, req);
// 在这里 获取到这个对象
return ret;
});
}

复杂点方案:自定义ActionHandler,继承ActionHandler,复制里面代码,改为自己业务的,再配置:
public void configHandler(Handlers me) {
me.setActionHandler(...)
}

2023-08-07 20:16

@hhchor 但是天笑分享的处理,就是有处理404返回的JSON呀。
除非是你Controller里面有index方法,这个是默认接收方法,如果里面代码没做返回数据处理的话,空的方法可能会返回异常RenderException。
最简单的就是里面不要写index方法。
当然以上为猜测,具体得看你代码是怎么写的了。比如是否有自定义ActionHandler之类的情况

2023-08-05 11:29

需要解释一下什么叫做 “如果路径存在,Controller方法不存在”,方便的话,贴下代码

2023-08-01 21:55

jfinal-undertow 开发下,src/main/resources/undertow.txt 文件里面加入一行配置:
### disable 是关闭不显示
undertow.serverName = disable
### 自定义比如
undertow.serverName = YunFinal

注意正式服一般会搭配NGINX代理,那么资源文件Server又会显示为NGINX了

2023-07-31 22:34

猜不到,是不是代码有 try 吃住异常了? 并且缺依赖jar?

2023-07-30 10:04

要获取 Java 类的注解,可以使用 Java 的反射机制和注解 API。
如:注解类 a= 目标类.class.getAnnotation(注解类.class);

网上搜索资料时,直接搜索Java XXX 就可以了,不用加JFinal,除非是要扩展JF的功能。比如下面两个扩展:
https://jfinal.com/share/2594
https://jfinal.com/share/2354

2023-07-25 09:52

因为分页有割掉order by,这种复杂的order by需要跳过一下,我之前有遇到过类似的需求,有加一个扩展处理进行跳过切割,
分享内容在: https://jfinal.com/share/2533
或者使用手册里面介绍的 https://jfinal.com/doc/5-6
第 "5、常见问题解决" 内容有介绍如何处理

2023-07-18 10:07

@北流家园网 普通JavaBean,没啥内容,就是固定了属性字段,因为Kv等类的属性是set进去的动态的,而返回结构第一级是固定格式,每次写比较麻烦。

2023-07-06 18:09

Enjoy 模板引擎专为 java 开发者打造,所以坚持两个核心设计理念:一是在模板中可以直接与 java 代码通畅地交互,二是尽可能沿用 java 语法规则,将学习成本降到极致。
因此,立即掌握 90% 的用法,只需要记住一句话:Enjoy 模板引擎表达式与 Java 是直接打通的。

这不是JF特色功能么? 只要不开放给前端无权限的自由填写就没问题了。

而且JF 5.0.2版本后,静态方法调用也改了:
Enjoy 模板引擎的静态方法调用与静态属性访问表达式默认值改为了 "不开启",如果用到这两类表达式,需要通过如下配置开启:
// 以下配置支持静态方法调用表达式:com.jfinal.kit.StrKit::isBlank('abc')
engine.setStaticMethodExpression(true);
// 以下配置支持静态属性访问表达式:com.jfinal.core.Constant::JFINAL_VERSION
engine.setStaticFieldExpression(true);