传文件,感谢UC
程序员文章站
2022-07-14 08:57:09
...
/** * */ package com.ly.rule; import java.util.HashMap; import java.util.Map; import org.apache.ibatis.ognl.Ognl; import org.apache.ibatis.ognl.OgnlContext; import org.apache.ibatis.ognl.OgnlException; /** * @author ly * */ public class OgnlDemo { /** * @param args */ public static void main(String[] args) { // test1(); // test2(); test0(); } private static void test0() { OgnlContext context = new OgnlContext(); Map<String, Object> obj = new HashMap<>(); obj.put("name", "test"); obj.put("user_age", new Integer(10)); obj.put("order_amount", new Double(3000)); context.setRoot(obj); String expression = "name == 'test' && user_age < 10 && order_amount > 3000"; try { Boolean result = (Boolean) Ognl.getValue(expression, context, context.getRoot()); System.out.println(result); } catch (OgnlException e) { e.printStackTrace(); } } private static void test1() { Foo foo = new Foo(); foo.setName("test"); User user = new User(); user.setAge(9); Order order = new Order(); order.setAmount(3003.56); OgnlContext context = new OgnlContext(); context.setRoot(foo); context.put("user", user); context.put("order", order); System.out.println(context.getValues()); String expression = "name == 'test' && #user.age < 10 && #order.amount > 3000"; try { Boolean result = (Boolean) Ognl.getValue(expression, context, context.getRoot()); System.out.println(result); } catch (OgnlException e) { e.printStackTrace(); } } private static void test2() { Foo foo = new Foo(); foo.setName("test"); User user = new User(); user.setAge(19); Order order = new Order(); order.setAmount(3003.56); OgnlContext context = new OgnlContext(); context.setRoot(foo); context.put("user", user); context.put("order", order); System.out.println(context.getValues()); String expression = "name == 'test' && #user.age < 10 && #order.amount > 3000"; try { Boolean result = (Boolean) Ognl.getValue(expression, context, context.getRoot()); System.out.println(result); } catch (OgnlException e) { e.printStackTrace(); } } } class Order { private double amount; public double getAmount() { return amount; } public void setAmount(double amount) { this.amount = amount; } @Override public String toString() { return "Order [amount=" + amount + "]"; } } class User { private int age; public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "User [age=" + age + "]"; } } class Foo { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "Foo [name=" + name + "]"; } }
上一篇: spring 常见错误
下一篇: 删除svn信息
推荐阅读
-
Node配合WebSocket做多文件下载以及进度回传
-
UC浏览器电脑版下载的文件在哪里?UC浏览器下载的文件位置查找方法介绍
-
qq怎么上传文件到微云?传文件到QQ微云空间的方法
-
IIS7传大于30M的视频时出现找不到文件或目录错误正确处理方法
-
uc云盘文中的文件怎么转存到360云盘?
-
钉钉怎么使用局域网传输文件? 钉钉传文件的教程
-
安卓Fast Share曝光:可快速传文件 类似iOS AirDrop
-
采用一些小窍门 内网的文件轻松传
-
mac和ipad如何互传文件呢?MAC传文件到IPAD方法介绍
-
30分钟玩转Net MVC 基于WebUploader的大文件分片上传、断网续传、秒传(文末附带demo下载)